Yet Another Contest 8 P2 - No More Modern Art

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Josh has a wall of colour X. However, last night, people graffitied the entire wall! Josh now needs to obtain a large amount of paint of colour X so that he can repaint the wall, covering up the modern art.

In his storeroom, Josh finds N buckets of paint. The i-th bucket has paint of colour a_i. Josh can repeatedly perform the following operation:

  • First, select one bucket of paint.
  • Then, evenly divide the paint in this bucket amongst the remaining buckets. The chosen bucket is then discarded.
  • If paint of colour X was poured into a bucket of paint of colour Y, then the bucket will now contain paint of colour X \oplus Y, due to the mysterious chemical properties of the paint.

Here, \oplus denotes the bitwise XOR operator.

Can you help Josh determine whether he can end up with exactly one bucket, with this bucket containing paint of colour X?

Constraints

2 \le N \le 10^6

0 \le X, a_i < 2^{30}

Subtask 1 [20%]

2 \le N \le 9

Subtask 2 [50%]

2 \le N \le 2000

Subtask 3 [30%]

No additional constraints.

Input Specification

The first line contains two space-separated integers, N and X.

The second line contains N space-separated integers, a_1, a_2, \dots, a_N.

Output Specification

On a single line, output YES if Josh can end up with a single bucket containing paint of colour X, and NO otherwise.

Sample Input 1

3 1
1 2 3

Sample Output 1

YES

Explanation for Sample Output 1

Initially, there are three buckets, containing paint of colours 1, 2 and 3 respectively. Even though Josh already has paint of colour 1, he wants a single bucket of colour X, with no other buckets.

First, Josh can pour the paint in bucket 1 into the other two buckets. The bucket which initially contained paint of colour 2 now contains paint of colour 1 \oplus 2 = 3. The bucket which initially contained paint of colour 3 now contains paint of colour 1 \oplus 3 = 2.

At this point, Josh has two buckets, containing paint of colours 3 and 2 respectively. If he pours the paint in the first bucket into the second bucket, he will end up with a single bucket containing paint of colour 3 \oplus 2 = 1.

Sample Input 2

3 4
1 2 3

Sample Output 2

NO

Comments

There are no comments at the moment.