测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A16826. XOR Array

编程题 普及-
知识点

题目描述

给定三个整数 $n$、$l$、$r$。

你需要生成一个长度为 $n$ 的正整数数组 $a$($1 \leq a_i \leq 10^9$)。定义 $f(x, y)$($1 \le x \le y \le n$)为按位异或 $a_x \oplus a_{x+1} \oplus \ldots \oplus a_y$。你需要保证
$$ \begin{cases} f(x, y) = 0 \quad \text{当且仅当 } x = l \text{ 且 } y = r; \\ f(x, y) \ne 0 \quad \text{当 } x \ne l \text{ 或 } y \ne r. \end{cases} $$

$^\text{∗}$ 其中 $\,\oplus\,$ 表示[按位异或运算](https://en.wikipedia.org/wiki/Bitwise_operation#XOR)。

输入格式

本题包含多组测试数据。第一行包含一个整数 $t$($1 \le t \le 10^4$),表示测试数据组数。

接下来每组测试数据一行,包含三个整数 $n$、$l$、$r$($2 \leq n \leq 4\cdot 10^5$,$1 \leq l < r \leq n$)。

保证所有测试数据中 $n$ 的总和不超过 $5\cdot 10^5$。

输出格式

对于每组测试数据,输出一行 $n$ 个整数 $a_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

说明/提示

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

- $f(1, 2) = 9 \oplus 8 = 1 \ne 0$,
- $f(2, 3) = 8 \oplus 1 = 9 \ne 0$,
- $f(1, 1) = 9 \ne 0$,
- $f(2, 2) = 8 \ne 0$,
- $f(3, 3) = 1 \ne 0$。

在第二个测试用例中,$2 \oplus 7 \oplus 5 = 0$,例如 $7 \oplus 5 \oplus 4 = 6 \ne 0$。
上一题 去做题 下一题