CF2175B.XOR Array

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given three integers nn, ll, and rr.

You need to generate an array aa of positive (1≤ai≤1091 \leq a_i \leq 10^9) integers of length nn. Let f(x,y)f(x, y), for 1≤x≤y≤n1 \le x \le y \le n, be the bitwise XOR∗^{\text{∗}} value ax⊕ax+1⊕…⊕aya_x \oplus a_{x+1} \oplus \ldots \oplus a_y. You need to make sure that $$\begin{cases} f(x, y) = 0\quad \text{when }x = l\text{ and }y = r; \text{and}\\ f(x, y) \ne 0\quad \text{when }x \ne l \text{ or } y \ne r. \end{cases}$$

∗^{\text{∗}}⊕\oplus denotes the bitwise XOR operation.

给你三个整数 nn、ll 和 rr。

你需要构造一个长度为 nn 的正整数数组 aa(满足 1≤ai≤1091 \leq a_i \leq 10^9)。定义函数 f(x,y)f(x, y)(其中 1≤x≤y≤n1 \le x \le y \le n)为子数组 ax⊕ax+1⊕…⊕aya_x \oplus a_{x+1} \oplus \ldots \oplus a_y 的按位异或∗^{\text{∗}}值。你需要确保

{f(x,y)=0当 x=l 且 y=r;且f(x,y)≠0当 x≠l 或 y≠r.\begin{cases} f(x, y) = 0\quad \text{当 }x = l\text{ 且 }y = r; \\ \text{且}\\ f(x, y) \ne 0\quad \text{当 }x \ne l \text{ 或 } y \ne r. \end{cases}

∗^{\text{∗}}⊕\oplus 表示按位异或运算。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The only line of each test case contains three integers nn, ll, and rr (2≤n≤4⋅1052 \leq n \leq 4\cdot 10^5, 1≤l<r≤n1 \leq l \lt r \leq n).

It is guaranteed that the sum of nn across all test cases does not exceed 5⋅1055\cdot 10^5.

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

每个测试用例仅有一行,包含三个整数 nn、ll 和 rr(2≤n≤4⋅1052 \leq n \leq 4\cdot 10^5,1≤l<r≤n1 \leq l \lt r \leq n)。

保证所有测试用例中 nn 的总和不超过 5⋅1055\cdot 10^5。

输出格式

For each test case, print a single line containing nn integers a1,a2,…ana_1, a_2, \ldots a_n.

We can show that an answer always exists. If there are multiple solutions, print any of them.

对于每个测试用例,输出一行包含 nn 个整数 a1,a2,…ana_1, a_2, \ldots a_n 的结果。

可以证明解总是存在的。如果存在多个解,输出其中任意一个即可。

输入输出样例

  • 输入#1

    4
    3 1 3
    4 1 3
    8 2 4
    4 3 4

    输出#1

    9 8 1 
    2 7 5 4 
    9 1 9 8 10 5 4 9
    85484 130377 6031 6031

说明/提示

In the first test case, f(1,3)=9⊕8⊕1=0f(1, 3) = 9 \oplus 8 \oplus 1 = 0, while all other non-empty subarrays have non-zero bitwise XOR:

  • f(1,2)=9⊕8=1≠0f(1, 2) = 9 \oplus 8 = 1 \ne 0,
  • f(2,3)=8⊕1=9≠0f(2, 3) = 8 \oplus 1 = 9 \ne 0,
  • f(1,1)=9≠0f(1, 1) = 9 \ne 0,
  • f(2,2)=8≠0f(2, 2) = 8 \ne 0,
  • f(3,3)=1≠0f(3, 3) = 1 \ne 0.

In the second test case, 2⊕7⊕5=02 \oplus 7 \oplus 5 = 0, while, for example, 7⊕5⊕4=6≠07 \oplus 5 \oplus 4 = 6 \ne 0.

在第一个测试用例中,f(1,3)=9⊕8⊕1=0f(1, 3) = 9 \oplus 8 \oplus 1 = 0,而所有其他非空子数组的按位异或值均不为零:

  • f(1,2)=9⊕8=1≠0f(1, 2) = 9 \oplus 8 = 1 \ne 0,
  • f(2,3)=8⊕1=9≠0f(2, 3) = 8 \oplus 1 = 9 \ne 0,
  • f(1,1)=9≠0f(1, 1) = 9 \ne 0,
  • f(2,2)=8≠0f(2, 2) = 8 \ne 0,
  • f(3,3)=1≠0f(3, 3) = 1 \ne 0。

在第二个测试用例中,2⊕7⊕5=02 \oplus 7 \oplus 5 = 0,而例如 7⊕5⊕4=6≠07 \oplus 5 \oplus 4 = 6 \ne 0。

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

首页