Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Comments
On mesanuCodeforces Round #817 (Div. 4), 20 months ago
0

Here's my solution: Observation 1: If the xorOdd == xorEven, then xorOdd ^ xorEven == 0, which mean xor of all elements is equal to 0.

This leads to observation 2: If n%4==0 then the answer is 0 to n-1. Consequentially, answer for n%4==3 is 1 to n.

if n%4==2 then we take the answer for n-3, then we add 3 numbers of our choice (mine was 2^30, 2^29 and 2^30 + 2^29).

if n%4==1 then we take answer for n-6, then we add 6 numbers.

AC code: 170284159

Bruh I knew how to solve D at 1h left but I got so many bugs it took me 1h past the contest to finally AC...

Because if bc/ad=x and x is an integer, then bc is divisible by ad by definition.

yeah D statement is really confusing

I got AC from an O(n*sqrt(n)) solution if you're interested

166988623 (AC)

166980959 (literally the exact same thing but TLE because mod operation is apparently a lot more costly than an if statement)

tfw you solved D but not C

God I absolutely hate div2C kind of problem where you're just trying to find this tiny obscure property that doesn't even look too relevant but turns out to be literally the whole answer

I assume what you meant is creating the longest subsequence by removing some elements in the original sequence.

In this case, we can try to solve the problem greedily.

First we construct a minheap.

Then we will iterate through the original sequence using a pointer i.

  • If the ith element is negative, put it in the heap.

  • When the sum of all elements from 1 to i becomes negative, we will remove the element with the smallest value using the minheap we just constructed. Since the removed elements will have the smallest possible value, I think the resulting sequence will be the longest possible sequence.

I couldn't prove/disprove this idea, but it seems to work.