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

Автор waidfj, история, 91 минуту назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

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

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

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

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

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

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$$$.