#P10307. 「Cfz Round 2」Binary

    ID: 11249 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>模拟洛谷原创O2优化位运算洛谷月赛

「Cfz Round 2」Binary

Problem Description

You are given n+1n + 1 integers a0ana_0 \dots a_n.

For an integer uu, suppose the bit positions where its binary representation is 11 are k1,k2kmk_1, k_2 \dots k_m. Then its weight is $f(u) = a_{k_1} \oplus a_{k_2} \oplus \dots \oplus a_{k_m}$. Here, the binary bit positions are numbered from right to left as 0,1,20,1,2\dots. The symbol \oplus denotes the bitwise XOR.

You want to know how many integers 0u2n10 \leq u \leq 2^n - 1 satisfy f(u)=f(u+1)f(u) = f(u + 1). For convenience, please output the answer in binary form (no modulo).

Note: The output must not contain leading 00, unless the answer is 00.

Input Format

This problem contains multiple test cases.

The first line contains an integer TT, the number of test cases.

Then the test cases follow. For each test case:

  • The first line contains a positive integer nn.
  • The second line contains n+1n + 1 integers a0ana_0 \dots a_n.

Output Format

For each test case, output one line containing a binary integer, which is the answer.

Reminder: The output must not contain leading 00, unless the answer is 00.

5
2
0 1 2
3
1 3 3 1
4
2 2 5 4 2
5
7 0 3 4 0 1
6
5 2 1 8 6 0 9
10
1
100
11
0

Hint

"Sample Explanation #1"

For the first test case:

  • (0)10=(0)2(0)_{10} = (0)_{2}, so f(0)=0f(0) = 0.
  • (1)10=(1)2(1)_{10} = (1)_{2}, so f(1)=a0=0f(1) = a_0 = 0.
  • (2)10=(10)2(2)_{10} = (10)_{2}, so f(2)=a1=1f(2) = a_1 = 1.
  • (3)10=(11)2(3)_{10} = (11)_{2}, so f(3)=a0a1=01=1f(3) = a_0 \oplus a_1 = 0 \oplus 1 = 1.
  • (4)10=(100)2(4)_{10} = (100)_{2}, so f(4)=a2=2f(4) = a_2 = 2.

Among them, we have f(0)=f(1)f(0) = f(1) and f(2)=f(3)f(2) = f(3), so the output is (2)10=(10)2(2)_{10} = (10)_{2}.

"Constraints"

Let n\sum n be the sum of nn within a single test file.

For all testdata, 1T1031 \leq T \leq 10^3, 1n2×1051 \leq n \leq 2\times 10^5, n6×105\sum n \leq 6\times 10^5, 0ai23010 \leq a_i \leq 2^{30} - 1.

Only if you pass all test points of this problem can you get the score for this problem.

Translated by ChatGPT 5