farmpiggie 与子集和AI (CI翻译)
For a permutation$^{\text{∗}}$ $p$ of even length, you can do the following process:
对于一个长度为偶数的排列$^{\text{∗}}$ $p$,可以进行如下过程:AI (CI翻译)
- Initialize a counter
$c = 0.$ - For each
$i$from$1$to$n,$either add$i \cdot p_i$to$c$, subtract$i \cdot p_i$from$c$, or do nothing.
- 初始化计数器
$c = 0.$ - 对于每个
$i$(从$1$到$n$),可以将$i \cdot p_i$加到$c$中,将$i \cdot p_i$从$c$中减去,或者什么也不做。
Let the final value of the counter be $c_{\mathrm{final}}.$
令计数器的最终值为 $c_{\mathrm{final}}.$AI (CI翻译)
Formally, for each $i \in \{1,\ldots,n\},$ consider the set $S_i = \{-i \cdot p_i, 0, i \cdot p_i\}$ and choose some $x_i \in S_i.$ Set $c_{\mathrm{final}} = \sum_{i = 1}^{n}x_i.$
形式化地,对于每个 $i \in \{1,\ldots,n\}$,考虑集合 $S_i = \{-i \cdot p_i, 0, i \cdot p_i\}$,并从中选择某个 $x_i \in S_i.$ 令 $c_{\mathrm{final}} = \sum_{i = 1}^{n}x_i.$AI (CI翻译)
You are given a single even integer $n$. Find any permutation of length $n$ so that regardless of the operations chosen, the final value $c_{\mathrm{final}}$ will not be $1.$
给定一个偶数 $n$。请找出任意一个长度为 $n$ 的排列,使得无论选择何种操作,最终值 $c_{\mathrm{final}}$ 都不会为 $1$。AI (CI翻译)
$^{\text{∗}}$A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array), and $[1,3,4]$ is also not a permutation ($n=3$ but there is $4$ in the array).
$^{\text{∗}}$长度为 $n$ 的排列是一个由 $1$ 到 $n$ 中的 $n$ 个互不相同的整数以任意顺序组成的数组。例如,$[2,3,1,5,4]$ 是一个排列,但 $[1,2,2]$ 不是排列(数组中 $2$ 出现了两次),$[1,3,4]$ 也不是排列($n=3$,但数组中出现了 $4$)。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 25$). The description of the test cases follows.
每个测试包含多个测试用例。第一行包含测试用例的数量 $t$($1 \le t \le 25$)。接下来描述各个测试用例。AI (CI翻译)
The first and only line of each test case contains a single even integer $n \, (2 \le n \le 50)$ — the length of the desired permutation.
每个测试用例的第一行且仅有一行包含一个偶数 $n$($2 \le n \le 50$)——所需排列的长度。AI (CI翻译)
Output
输出
AI (CI翻译)For each test case, output $n$ integers $p_1, \ldots, p_n \, (1 \le p_i \le n)$ — a permutation satisfying the conditions.
对于每个测试用例,输出 $n$ 个整数 $p_1, \ldots, p_n$($1 \le p_i \le n$)——一个满足条件的排列。AI (CI翻译)
If there are multiple solutions, print any of them.
如果有多个解,输出任意一个即可。AI (CI翻译)
Note
说明
AI (CI翻译)In the first test case, the permutation given in the output is $[2,1].$ The counter may be incremented in the following $9$ ways:
在第一个测试用例中,输出中的排列为 $[2,1]$。计数器可能以下列 $9$ 种方式变化:AI (CI翻译)
$0 \xrightarrow{+2 \cdot 1} 2 \xrightarrow{+0} 2$$0 \xrightarrow{+0} 2 \xrightarrow{+1 \cdot 2} 2$$0 \xrightarrow{-2 \cdot 1} -2 \xrightarrow{+0} -2$$0 \xrightarrow{+0} 2 \xrightarrow{-1 \cdot 2} -2$$0 \xrightarrow{-2 \cdot 1} -2 \xrightarrow{+1 \cdot 2} 0$$0 \xrightarrow{+2 \cdot 1} 2 \xrightarrow{-1 \cdot 2} 0$$0 \xrightarrow{-2 \cdot 1} -2 \xrightarrow{-1 \cdot 2} -4$$0 \xrightarrow{+2 \cdot 1} 2 \xrightarrow{+1 \cdot 2} 4.$$0 \xrightarrow{+0} 0 \xrightarrow{+0} 0.$
$0 \xrightarrow{+2 \cdot 1} 2 \xrightarrow{+0} 2$$0 \xrightarrow{+0} 2 \xrightarrow{+1 \cdot 2} 2$$0 \xrightarrow{-2 \cdot 1} -2 \xrightarrow{+0} -2$$0 \xrightarrow{+0} 2 \xrightarrow{-1 \cdot 2} -2$$0 \xrightarrow{-2 \cdot 1} -2 \xrightarrow{+1 \cdot 2} 0$$0 \xrightarrow{+2 \cdot 1} 2 \xrightarrow{-1 \cdot 2} 0$$0 \xrightarrow{-2 \cdot 1} -2 \xrightarrow{-1 \cdot 2} -4$$0 \xrightarrow{+2 \cdot 1} 2 \xrightarrow{+1 \cdot 2} 4.$$0 \xrightarrow{+0} 0 \xrightarrow{+0} 0.$
None of these are $1,$ so the permutation satisfies the given condition.
其中没有一个最终值为 $1$,因此该排列满足题目条件。AI (CI翻译)
We can show that the permutation given in the second test case satisfies the condition. However, the permutation $[1,2,3,4]$ would not satisfy the condition, since the sequence $$0 \xrightarrow{+1 \cdot 1} 1 \xrightarrow{+0} 1 \xrightarrow{+0} 1 \xrightarrow{+0} 1$$ results in $c = 1$ at the end.
我们可以证明,第二个测试用例中给出的排列满足题目条件。然而,排列 $[1,2,3,4]$ 不满足题目条件,因为序列 $$0 \xrightarrow{+1 \cdot 1} 1 \xrightarrow{+0} 1 \xrightarrow{+0} 1 \xrightarrow{+0} 1$$ 最终得到的 $c = 1$。AI (CI翻译)
样例
3
2
4
6
2 1
2 3 4 1
5 4 6 2 1 3
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。