I am not going to prove you why my solution is right. This is a very popular game called Nim. Lets say we have n stones a1, a2, ... , an
If, and only if, a1 xor a2 xor ... xor an = 0 =) 'NO'
a1 xor a2 xor ... xor an <> 0 =) 'YES'
I don't uderstand why I have WA. I use Erdos and Gallai (1960) theorem. At first I check if the sum is odd, if there is element bigger than n or if there is a negative element. Than I sort the degree sequence and used two index trees to implement Erdos and Gallai (1960) theorem. Help me please :( Or ...