Help Walter White

0

0 votes
Problem

Walter White is working on getting a new chemistry invention on his name, but he needs your help to do it. He has already prepared N solutions, each possessing strength si (1<=si<=1e9). 
He needs to club all these solutions together by performing an operation every time on each present set of chemicals.
The operation involves taking some portion of two adjacent chemicals and mixing them to create a new solution, and this new solution gets the strength value of the XOR of the constituent solutions it was made up of.
For example, mixing s[i] and s[i+1] will give you a new solution with strength of s[i]^s[i+1].

The result of bitwise XOR operator is 1 if the corresponding bits of two operands are opposite( 0^1 or 1^0), other wise the result is 0 (0^0 or 1^1) It is denoted by ^

He performs this operation K times on the initial chemicals present, and lastly has some a smaller set of chemicals left. He wants to find out the strength of the Pth chemical solution. (P is 0 indexed) Can you help him?

 

Input Format

3 lines containing N, K, P respectively.

1 line containing the already made N solutions

Output Format

1 number containing the strength of the Pth chemical solution after K rounds of mixing.

Constraints

1<=N<=1e5
1<K<N
0<=P<N-K
1<=S[i]<=1e9

 

 

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

After first operation, solution set = 3 7 5 14 10 ( 6 ^ 5 = 3, 5^2=7. 2^7=5,7^9=14, 9^3=10)
After second operation, set =  4 2 11 4 ( 3^7=4, 7^5=2, 5^14=11, 14^10=4)
After third operation, set =  6 9 15 (4^2=6, 2^11=9, 11^4=15)

Now since P=2, the answer is 15(assuming 0 indexing)

Editor Image

?