Codeforces Round 1099 (Div. 2)
A
构造一个数组
Construct an Array
Codeforces
800
原题
←B →

构造一个数组AI (CI翻译)

You are given an integer $n$. You need to construct an array of integers $a_1, a_2, \ldots, a_n$ such that the following conditions are satisfied:

给定一个整数 $n$。你需要构造一个由整数 $a_1, a_2, \ldots, a_n$ 组成的数组,使其满足以下条件:AI (CI翻译)

  • $1 \leq a_i \leq 2 \cdot n$ for all $i$ from $1$ to $n$.
  • All elements of the array and the sums of adjacent elements are pairwise distinct. In other words, among the numbers $\{a_1, a_2, \ldots, a_n, a_1 + a_2, a_2 + a_3, \ldots, a_{n - 1} + a_n\}$, there should not be two equal numbers.
  • 对于从 $1$ 到 $n$ 的所有 $i$,都有 $1 \leq a_i \leq 2 \cdot n$。
  • 数组中的所有元素以及相邻元素之和两两不同。换句话说,在数集 $\{a_1, a_2, \ldots, a_n, a_1 + a_2, a_2 + a_3, \ldots, a_{n - 1} + a_n\}$ 中,任意两个数都不相等。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). The description of the test cases follows.

每个输入包含多组测试用例。第一行包含测试用例数 $t$($1 \le t \le 100$)。接下来是各测试用例的描述。AI (CI翻译)

The only line of each test case contains one integer $n$ ($1 \le n \le 500$).

每个测试用例仅包含一行,其中有一个整数 $n$($1 \le n \le 500$)。AI (CI翻译)

Output

输出格式

AI (CI翻译)

For each test case, output an array of length $n$ that satisfies the condition of the problem. It can be shown that such an array always exists under the given constraints.

对于每个测试用例,输出一个长度为 $n$ 且满足题目条件的数组。可以证明,在给定约束下,这样的数组总是存在。AI (CI翻译)

Note

说明

AI (CI翻译)

In the second example, all elements and adjacent sums form the set $\textbf{6}, \textbf{2}, \textbf{3}, 8, 5$, all of whose elements are distinct.

在第二个样例中,所有元素及相邻元素之和组成集合 $\textbf{6}, \textbf{2}, \textbf{3}, 8, 5$,其中的元素两两不同。AI (CI翻译)

In the third example, all elements and adjacent sums form the set $\textbf{8}, \textbf{1}, \textbf{11}, \textbf{2}, \textbf{3}, \textbf{4}, 9, 12, 13, 5, 7$, whose elements are also distinct.

在第三个样例中,所有元素及相邻元素之和组成集合 $\textbf{8}, \textbf{1}, \textbf{11}, \textbf{2}, \textbf{3}, \textbf{4}, 9, 12, 13, 5, 7$,其中的元素也两两不同。AI (CI翻译)

样例

Input #1
3
1
3
6
Output #1
1
6 2 3
8 1 11 2 3 4
InputCopy OutputCopy
题目信息
题号
2231A
时间限制
1 s
内存限制
256 MB
标签
构造

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。