Increasing XOR

Time limit: 1s Memory limit: 256MB Input: Output:

Task

An array BB consisting of kk positive integers is beautiful if and only if there exists an array C=[C0,C1,,Ck1]C = [C_0, C_1, \ldots, C_{k-1}] such that CC is a permutation of BB and the sequence of its prefix-XORs is strictly increasing. That is, P0<P1<<Pk1P_0 < P_1 < \dots < P_{k-1} where Pi=C0C1CiP_i = C_0 \oplus C_1 \oplus \dots C_i for each i=0,,k1i = 0, \dots, k-1.

The bitwise XOR aba \oplus b of two integers aa and bb is defined in the following way:
the ii-th bit of aba \oplus b is 11 if and only if exactly one among aa and bb has 11 in the ii-th bit.

The XOR symbol.\text{The XOR symbol.}

Given an array AA consisting of NN positive integers, you have to determine for each non-empty prefix of AA whether it is beautiful.

Input data

The first line contains the only integer NN. The second line contains NN integers, A0,A1,,AN1A_0, A_1, \dots, A_{N-1}.

Output data

You should print NN lines. In the iith line, you must write YES if the iith prefix is beautiful and NO otherwise.

Constraints and clarifications

  • 1N200 0001 \le N \le 200 \ 000.
  • 1Ai<2301 \le A_i < 2^{30} for each i=0N1i=0\ldots N-1.
# Points Constraints
1 0 Examples.
2 10 N10N \le 10
3 11 Ai7A_i \le 7 for each i=0N1i=0\ldots N-1
4 35 N500N \le 500
5 44 No additional limitations.

Example 1

stdin

5
3 1 4 1 5

stdout

YES
YES
YES
YES
NO

Explanation

In the first sample case:

  • The 11st prefix is beautiful because a sequence consisting of a single element is, by definition, strictly increasing.
  • For the 22nd prefix, the permutation 1,31, 3 is suitable as the sequence 1,2=131, 2 = 1 \oplus 3 is strictly increasing.
  • For the 33rd prefix, the permutation 1,3,41, 3, 4 is suitable as the sequence 1,2=13,6=1341, 2 = 1 \oplus 3, 6 = 1 \oplus 3 \oplus 4 is strictly increasing.
  • For the 44th prefix, the permutation 1,3,4,11, 3, 4, 1 is suitable as the sequence 1,2,6,71, 2, 6, 7 is strictly increasing.
  • It can be checked that the 55th prefix is not beautiful.

Example 2

stdin

5
3 3 5 8 19

stdout

YES
NO
NO
NO
YES

Log in or sign up to be able to send submissions!