CF1863F.Divide, XOR, and Conquer

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array of nn integers a1,a2,,ana_1, a_2, \ldots, a_n .

In one operation you split the array into two parts: a non-empty prefix and a non-empty suffix. The value of each part is the bitwise XOR of all elements in it. Next, discard the part with the smaller value. If both parts have equal values, you can choose which one to discard. Replace the array with the remaining part.

The operations are being performed until the length of the array becomes 11 . For each ii ( 1in1 \le i \le n ), determine whether it is possible to achieve the state when only the ii -th element (with respect to the original numbering) remains.

Formally, you have two numbers ll and rr , initially l=1l = 1 and r=nr = n . The current state of the array is [al,al+1,,ar][a_l, a_{l+1}, \ldots, a_r] .

As long as l<rl < r , you apply the following operation:

  • Choose an arbitrary kk from the set {l,l+1,,r1}\{l, l + 1, \ldots, r - 1\} . Denote x=alal+1akx = a_l \oplus a_{l + 1} \oplus \ldots \oplus a_k and y=ak+1ak+2ary = a_{k + 1} \oplus a_{k + 2} \oplus \ldots \oplus a_{r} , where \oplus denotes the bitwise XOR operation.
  • If x<yx < y , set l=k+1l = k + 1 .
  • If x>yx > y , set r=kr = k .
  • If x=yx = y , either set l=k+1l = k + 1 , or set r=kr = k .

For each ii ( 1in1 \le i \le n ), determine whether it is possible to achieve l=r=il = r = i .

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t100001 \le t \le 10\,000 ). The description of the test cases follows.

The first line of each test case contains one integer nn ( 1n100001 \le n \le 10\,000 ).

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 0ai<2600 \le a_i < 2^{60} ).

It is guaranteed that the sum of nn over all test cases does not exceed 1000010\,000 .

输出格式

For each test case, output a single string of length nn where the ii -th element is equal to 1 if it is possible to achieve l=r=il = r = i and is equal to 0 otherwise.

输入输出样例

  • 输入#1

    6
    6
    3 2 1 3 7 4
    5
    1 1 1 1 1
    10
    1 2 4 8 4 1 2 3 4 5
    5
    0 0 0 0 0
    5
    1 2 3 0 1
    1
    100500

    输出#1

    111111
    10101
    0001000000
    11111
    11001
    1

说明/提示

In the first test case, it is possible to achieve l=r=il = r = i for any ii from 11 to nn :

  • for i=1i=1 : [1;6][1;4][1;1][1; 6] \rightarrow [1; 4] \rightarrow [1; 1] ;
  • for i=2i=2 : [1;6][1;3][2;3][2;2][1; 6] \rightarrow [1; 3] \rightarrow [2; 3] \rightarrow [2; 2] ;
  • for i=3i=3 : [1;6][1;3][3;3][1; 6] \rightarrow [1; 3] \rightarrow [3; 3] ;
  • for i=4i=4 : [1;6][1;4][4;4][1; 6] \rightarrow [1; 4] \rightarrow [4; 4] ;
  • for i=5i=5 : [1;6][5;6][5;5][1; 6] \rightarrow [5; 6] \rightarrow [5; 5] ;
  • for i=6i=6 : [1;6][6;6][1; 6] \rightarrow [6; 6] .

Let's take a closer look at i=2i = 2 . Initially l=1l = 1 , r=6r = 6 .

  1. We can choose k=3k = 3 and set r=k=3r = k = 3 since (321)=00=(374)(3 \oplus 2 \oplus 1) = 0 \ge 0 = (3 \oplus 7 \oplus 4) ;
  2. Next, we can choose k=1k = 1 and set l=k+1=2l = k + 1 = 2 since 33=(21)3 \le 3 = (2 \oplus 1) ;
  3. Finally, we can choose k=2k = 2 and set r=k=2r = k = 2 since 212 \ge 1 .
首页