eren__'s blog

By eren__, 24 hours ago, In English

⭐ 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
  • Vote: I like it
  • +35
  • Vote: I do not like it

»
6 hours ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

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 ?????????

»
6 hours ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

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)'.

»
6 hours ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

E feels soooo hard

»
5 hours ago, hide # |
← Rev. 5  
Vote: I like it 0 Vote: I do not like it

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 :)

»
5 hours ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

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.

»
4 hours ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

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

»
4 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

Code
»
3 hours ago, hide # |
← Rev. 2  
Vote: I like it +1 Vote: I do not like it

392257923

Just barely optimized my $$$O(n^\frac{5}{3}\log A)$$$ solution for 2E/1C to pass (idea is binary search + 3D Mo's). It's probably hackable; have fun trying!

»
16 minutes ago, hide # |
← Rev. 3  
Vote: I like it 0 Vote: I do not like it

Really nice contest, i think for $$$1B$$$ you could also generate the graph for all the $$$16$$$ numbers, and see that all multiples of $$$5$$$ and $$$3$$$ (and $$$0$$$) are a maximal connected component, all the other elements cannot reach this component. This is much lazier then the editorial approach but maybe more intuitive during a contest (i did it like this when i upsolved it).