Блог пользователя eren__

Автор eren__, 20 часов назад, По-английски

⭐ Hope you enjoyed the problems! ⭐

2269A - SauSaGe Bank

Idea: Hamed_Ghaffari
Preparation: Hamed_Ghaffari

Hints
Solution
Code

2269B - KiaKio and Squared Numbers

Idea: sweetweasel
Preparation: sweetweasel

Hints
Solution
Code

2269C - K Is Important / 2268A - K Is Important

Idea: eren__
Preparation: eren__

Hints
Solution
Code

2269D - What a SauSaGe! It's All Meat / 2268B - What a SauSaGe! It's All Meat

Idea: _R00T
Preparation: _R00T

Hints
Solution
Code

2269E - KiaKio and Energy Intervals / 2268C - KiaKio and Energy Intervals

Idea: sweetweasel
Preparation: sweetweasel

Hints
Solution
Code

2269F - AghaBalaSar and Hamed / 2268D - AghaBalaSar and Hamed

Idea: Hamed_Ghaffari
Preparation: Hamed_Ghaffari

What is AghaBalaSar?
Hints
Solution
Code

2268E - Kia Kio and Tree of Life

Idea: sweetweasel
Preparation: Hamed_Ghaffari and _R00T

Hints
Solution
Code

2268F - Deglado

Idea: eren__
Preparation: Hamed_Ghaffari and _R00T

Hints
Solution
Code
Challenge
  • Проголосовать: нравится
  • +21
  • Проголосовать: не нравится

»
2 часа назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

The gap between D and E is very huge, as 1400 to 2300.

And why $$$O(n^2)$$$ or $$$O(n\log^3n)$$$ can pass E's system test ?????????

»
119 минут назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

In Hint 2 of the editorial for 1F, I believe you meant '2n*comb(2n, 2) inversions in the worst case', rather than 'n*comb(2n, 2)'.

»
106 минут назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

E feels soooo hard

»
69 минут назад, скрыть # |
← Rev. 5  
Проголосовать: нравится 0 Проголосовать: не нравится

In problem D you can also generate the set of possible values and check if the array value belongs to the set or not

Code

PS: I'm sure there are better ways to calculate the set but this seemed to work so why not :)

»
53 минуты назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

I feel like another solution of D2D/D1B should be mentioned, making the problem not as ad-hoc (and I think that the fact that xor basis of $$$3k$$$ generates exactly all masks with even popcount is a prime example ad-hoc, because it works up to 4 bits).

The solution is as follows: let's do segment tree, and in each node we'll store $$$dp[start][end]$$$ — maximum number of positions on the interval of the node, if we also xor the first element with value $$$start$$$ and the last element $$$end$$$, these operations cover out-of-bounds elements. Then to merge two nodes we actually need to do matrix multiplication, but with operations $$$(\max, +)$$$: $$$dp[s][e] = \max_t dpl[s][t] + dpr[t][e]$$$. The answer is $$$dp[0][0]$$$ in the root node. This solution works in $$$O(16^3 \log n)$$$, which is a lot. But, maybe not every value of xor can be achieved, if we precalc the set of possible values, we get $$$0,3,5,6,9,10,12,15$$$ — $$$8$$$ elements istead of $$$16$$$. Now matrix multiplication takes $$$8^3$$$ operations and the solution passes.

»
26 минут назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

A general Segment Tree + DP solution that doesn't rely on the ai < 16 restriction and works for any ai : note that adjacent pair updates telescope into assigning a net XOR shift vi in W to each element ai, which is valid if and only if the total XOR sum of vi's = 0, where W = span of {3,6,9,12,15} = {0,3,5,6,9,10,12,15} is an 8-element subspace. We can maintain a segment tree where each node stores dp[v] — the maximum number of elements divisible by 3 in its range given a total accumulated XOR sum is v. At a leaf, dp[v] = ((a[i] ^ v) % 3 == 0 ? 1 : 0), and to merge two nodes, we perform XOR group convolution: dp_parent[x ^ y] = max(dp_parent[x ^ y], dp_left[x] + dp_right[y]) for all x, y in W. The answer is dp[0] at the root node, and updates take O(|W|^2 *log N) = O(64 * log N) time.

my submission: https://codeforces.me/contest/2269/submission/392215444

»
16 минут назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In B, why dont simply repeat the operations until a stable state is reached? (it is accepted)

Code