waidfj's blog

By waidfj, history, 43 minutes ago, In English

I am struggling with a small issue in 2271C - XOR Problem of today's contest.

For n = 2, my code gave this array as output: [2, 1, 0, 2, 0, 1, 2] and it passed the judge's test. However, I just read the expected answer [0, 2, 0, 1, 0, 2, 0] and now I think that my output should've gotten wrong.

Looking at the expected answer, it has a length of 7 and 0 subarrays, and thus the beauty of it is 7. But in my array its length is 7 and it has 2 subbarrays ([2, 1, 0, 2, 0, 1] and [1, 0, 2, 0, 1, 2]) which gives it a beauty of 5, which is not the maximum, which means it's wrong.

Can someone please help me understand if I'm missing something, why was my array judged accurate? 394017566

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
31 minute(s) ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Your solution has 4 subarrays with xor 0

The 2 you listed + the 2 zeros

The expected answer has 4(the 4 zeros)

Because the xor of an array length 1 is that element

  • »
    »
    12 minutes ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Oooooooooooh I totally missed that, thank you!!! I was testing my logic with that code, but it broke my entire thinking direction when it passed :(

»
26 minutes ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Subarrays of length 1 are also valid, so both arrays have four 0-subarrays, including the zeros. Yours have $$$(l, r)\in\lbrace(0, 5), (1, 6), (2, 2), (4, 4)\rbrace$$$. Expected answer has $$$(l, r)\in\lbrace(0, 0), (2, 2), (4, 4), (6, 6)\rbrace$$$.