CF1863F.Divide, XOR, and Conquer

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

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 (1≤i≤n1 \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 \lt r, you apply the following operation:

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

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

给你一个包含 nn 个整数的数组 a1,a2,…,ana_1, a_2, \ldots, a_n。

每次操作中,你将当前数组划分为两部分:一个非空前缀和一个非空后缀。每部分的值定义为该部分中所有元素的按位异或(XOR)。接着,丢弃值较小的那一部分;若两部分值相等,则可任选其一丢弃。用剩余部分替换当前数组。

重复执行上述操作,直到数组长度变为 11。对每个 ii(1≤i≤n1 \le i \le n),判断是否可能达到仅剩原数组中第 ii 个元素(按原始编号)的状态。

形式化地,你维护两个整数 ll 和 rr,初始时 l=1l = 1、r=nr = n,当前数组状态为 [al,al+1,…,ar][a_l, a_{l+1}, \ldots, a_r]。

只要 l<rl \lt r,就执行如下操作:

  • 任选一个 kk,满足 k∈{l,l+1,…,r−1}k \in \{l, l + 1, \ldots, r - 1\}。记 x=al⊕al+1⊕…⊕akx = a_l \oplus a_{l + 1} \oplus \ldots \oplus a_k,y=ak+1⊕ak+2⊕…⊕ary = a_{k + 1} \oplus a_{k + 2} \oplus \ldots \oplus a_{r},其中 ⊕\oplus 表示按位异或运算。
  • 若 x<yx \lt y,则令 l=k+1l = k + 1;
  • 若 x>yx \gt y,则令 r=kr = k;
  • 若 x=yx = y,则可任选令 l=k+1l = k + 1 或令 r=kr = k。

对每个 ii(1≤i≤n1 \le i \le n),判断是否可能达到 l=r=il = r = i 的状态。

输入格式

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

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

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

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

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤10 0001 \le t \le 10\,000)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤10 0001 \le n \le 10\,000)。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai<2600 \le a_i \lt 2^{60})。

保证所有测试用例的 nn 值之和不超过 10 00010\,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.

对于每个测试用例,输出一个长度为 nn 的字符串,其中第 ii 个元素在能够实现 l=r=il = r = i 时为 1,否则为 0。

输入输出样例

  • 输入#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 (3⊕2⊕1)=0≥0=(3⊕7⊕4)(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 3≤3=(2⊕1)3 \le 3 = (2 \oplus 1);
  3. Finally, we can choose k=2k = 2 and set r=k=2r = k = 2 since 2≥12 \ge 1.

在第一个测试用例中,对于任意 ii(1≤i≤n1 \le i \le n),均可实现 l=r=il = r = i:

  • 对于 i=1i=1:[1;6]→[1;4]→[1;1][1; 6] \rightarrow [1; 4] \rightarrow [1; 1];
  • 对于 i=2i=2:[1;6]→[1;3]→[2;3]→[2;2][1; 6] \rightarrow [1; 3] \rightarrow [2; 3] \rightarrow [2; 2];
  • 对于 i=3i=3:[1;6]→[1;3]→[3;3][1; 6] \rightarrow [1; 3] \rightarrow [3; 3];
  • 对于 i=4i=4:[1;6]→[1;4]→[4;4][1; 6] \rightarrow [1; 4] \rightarrow [4; 4];
  • 对于 i=5i=5:[1;6]→[5;6]→[5;5][1; 6] \rightarrow [5; 6] \rightarrow [5; 5];
  • 对于 i=6i=6:[1;6]→[6;6][1; 6] \rightarrow [6; 6]。

我们来更详细地考察 i=2i = 2 的情形。初始时 l=1l = 1,r=6r = 6。

  1. 我们可选择 k=3k = 3,并将 rr 设为 k=3k = 3,因为 (3⊕2⊕1)=0≥0=(3⊕7⊕4)(3 \oplus 2 \oplus 1) = 0 \ge 0 = (3 \oplus 7 \oplus 4);
  2. 接着,我们可选择 k=1k = 1,并将 ll 设为 k+1=2k + 1 = 2,因为 3≤3=(2⊕1)3 \le 3 = (2 \oplus 1);
  3. 最后,我们可选择 k=2k = 2,并将 rr 设为 k=2k = 2,因为 2≥12 \ge 1。

输入解题思路,AI测评打分。不知道怎么写?

首页