cswork / OA打开练习工作台

Goldman SachsOA #23

Bitwise XOR Subsequences

估计中等可在线判题

考点(AI 标注)哈希计数子序列

Find the longest subsequence of the array such that the bitwise XOR of every pair of adjacent chosen elements equals k. A subsequence of length 1 is always valid.

输入格式

The first line contains n (1..100000), followed by n lines, each with one arr[i] (0..10^6), and a final line with k (0..10^6).

输出格式

Output the length of the longest valid subsequence.

样例 1

输入:

4
1
2
3
4
3

输出:

2

样例 2

输入:

1
5
0

输出:

1

样例 3

输入:

4
2
2
2
2
0

输出:

4