CF2175B.XOR Array
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given three integers n, l, and r.
You need to generate an array a of positive (1≤ai≤109) integers of length n. Let f(x,y), for 1≤x≤y≤n, be the bitwise XOR∗ value ax⊕ax+1⊕…⊕ay. 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}$$
∗⊕ denotes the bitwise XOR operation.
给你三个整数 n、l 和 r。
你需要构造一个长度为 n 的正整数数组 a(满足 1≤ai≤109)。定义函数 f(x,y)(其中 1≤x≤y≤n)为子数组 ax⊕ax+1⊕…⊕ay 的按位异或∗值。你需要确保
⎩⎨⎧f(x,y)=0当 x=l 且 y=r;且f(x,y)=0当 x=l 或 y=r.
∗⊕ 表示按位异或运算。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The only line of each test case contains three integers n, l, and r (2≤n≤4⋅105, 1≤l<r≤n).
It is guaranteed that the sum of n across all test cases does not exceed 5⋅105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例仅有一行,包含三个整数 n、l 和 r(2≤n≤4⋅105,1≤l<r≤n)。
保证所有测试用例中 n 的总和不超过 5⋅105。
输出格式
For each test case, print a single line containing n integers a1,a2,…an.
We can show that an answer always exists. If there are multiple solutions, print any of them.
对于每个测试用例,输出一行包含 n 个整数 a1,a2,…an 的结果。
可以证明解总是存在的。如果存在多个解,输出其中任意一个即可。
输入输出样例
输入#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=0, while all other non-empty subarrays have non-zero bitwise XOR:
- f(1,2)=9⊕8=1=0,
- f(2,3)=8⊕1=9=0,
- f(1,1)=9=0,
- f(2,2)=8=0,
- f(3,3)=1=0.
In the second test case, 2⊕7⊕5=0, while, for example, 7⊕5⊕4=6=0.
在第一个测试用例中,f(1,3)=9⊕8⊕1=0,而所有其他非空子数组的按位异或值均不为零:
- f(1,2)=9⊕8=1=0,
- f(2,3)=8⊕1=9=0,
- f(1,1)=9=0,
- f(2,2)=8=0,
- f(3,3)=1=0。
在第二个测试用例中,2⊕7⊕5=0,而例如 7⊕5⊕4=6=0。
输入解题思路,AI测评打分。不知道怎么写?