English · Original
Chinese · Translation
Formal · Original
Seyyed and MoJaK are friends of Sajjad. Sajjad likes a permutation. Seyyed wants to change the permutation in a way that Sajjad won't like it. Seyyed thinks more swaps yield more probability to do that, so he makes MoJaK to perform a swap between every pair of positions (_i_, _j_), where _i_ < _j_, exactly once. MoJaK doesn't like to upset Sajjad.
Given the permutation, determine whether it is possible to swap all pairs of positions so that the permutation stays the same. If it is possible find how to do that.
## Input
The first line contains single integer _n_ (1 ≤ _n_ ≤ 1000) — the size of the permutation.
As the permutation is not important, you can consider _a__i_ = _i_, where the permutation is _a_1, _a_2, ..., _a__n_.
## Output
If it is not possible to swap all pairs of positions so that the permutation stays the same, print "_NO_",
Otherwise print "_YES_", then print lines: the _i_\-th of these lines should contain two integers _a_ and _b_ (_a_ < _b_) — the positions where the _i_\-th swap is performed.
[samples]
Seyyed 和 MoJaK 是 Sajjad 的朋友。Sajjad 喜欢一个排列。Seyyed 希望通过某种方式改变这个排列,使得 Sajjad 不再喜欢它。Seyyed 认为交换次数越多,成功改变排列的概率就越大,因此他让 MoJaK 对每一对位置 #cf_span[(i, j)](其中 #cf_span[i < j])恰好执行一次交换。但 MoJaK 不想让 Sajjad 不开心。
给定一个排列,请判断是否可能通过执行所有位置对的交换,使得排列最终保持不变。如果可能,请给出一种具体的交换方案。
第一行包含一个整数 #cf_span[n](#cf_span[1 ≤ n ≤ 1000])——排列的大小。
由于排列本身不重要,你可以假设 #cf_span[ai = i],即排列为 #cf_span[a1, a2, ..., an]。
如果不可能通过执行所有位置对的交换使排列保持不变,请输出 "_NO_";
否则输出 "_YES_",然后输出 #cf_span[\binom{n}{2}] 行:第 #cf_span[i] 行应包含两个整数 #cf_span[a] 和 #cf_span[b](#cf_span[a < b]),表示第 #cf_span[i] 次交换发生在位置 #cf_span[a] 和 #cf_span[b] 上。
## Input
第一行包含一个整数 #cf_span[n](#cf_span[1 ≤ n ≤ 1000])——排列的大小。由于排列本身不重要,你可以假设 #cf_span[ai = i],即排列为 #cf_span[a1, a2, ..., an]。
## Output
如果不可能通过执行所有位置对的交换使排列保持不变,请输出 "_NO_";否则输出 "_YES_",然后输出 #cf_span[\binom{n}{2}] 行:第 #cf_span[i] 行应包含两个整数 #cf_span[a] 和 #cf_span[b](#cf_span[a < b]),表示第 #cf_span[i] 次交换发生在位置 #cf_span[a] 和 #cf_span[b] 上。
[samples]
**Definitions**
Let $ n \in \mathbb{Z} $, $ n \geq 1 $.
Let $ \sigma \in S_n $ be the identity permutation: $ \sigma(i) = i $ for all $ i \in \{1, \dots, n\} $.
Let $ \mathcal{P} = \{ (i,j) \mid 1 \leq i < j \leq n \} $ be the set of all unordered pairs of distinct indices.
**Constraints**
1. $ 1 \leq n \leq 1000 $
2. Each pair $ (i,j) \in \mathcal{P} $ is swapped **exactly once**, in some order.
**Objective**
Determine whether there exists an ordering of the swaps $ (i_1, j_1), (i_2, j_2), \dots, (i_m, j_m) $, where $ m = \binom{n}{2} $, such that the composition of these transpositions leaves $ \sigma $ unchanged.
That is, let $ \tau_1, \tau_2, \dots, \tau_m $ be the transpositions corresponding to the swaps.
We require:
$$
\tau_m \circ \tau_{m-1} \circ \cdots \circ \tau_1 \circ \sigma = \sigma
$$
Equivalently, the product of all transpositions must be the identity permutation:
$$
\prod_{(i,j) \in \mathcal{P}} (i\;j) = \mathrm{id}
$$
**Note**: The product of all transpositions in $ S_n $ is the identity **if and only if** $ n \equiv 0 \pmod{4} $ or $ n \equiv 1 \pmod{4} $.
Thus:
- If $ n \equiv 2 \pmod{4} $ or $ n \equiv 3 \pmod{4} $, output "_NO_".
- Otherwise, output "_YES_" and list all pairs $ (i,j) $ with $ i < j $ in any order.
API Response (JSON)
{
"problem": {
"name": "E. The same permutation",
"description": {
"content": "Seyyed and MoJaK are friends of Sajjad. Sajjad likes a permutation. Seyyed wants to change the permutation in a way that Sajjad won't like it. Seyyed thinks more swaps yield more probability to do tha",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF804E"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Seyyed and MoJaK are friends of Sajjad. Sajjad likes a permutation. Seyyed wants to change the permutation in a way that Sajjad won't like it. Seyyed thinks more swaps yield more probability to do tha...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "Seyyed 和 MoJaK 是 Sajjad 的朋友。Sajjad 喜欢一个排列。Seyyed 希望通过某种方式改变这个排列,使得 Sajjad 不再喜欢它。Seyyed 认为交换次数越多,成功改变排列的概率就越大,因此他让 MoJaK 对每一对位置 #cf_span[(i, j)](其中 #cf_span[i < j])恰好执行一次交换。但 MoJaK 不想让 Sajjad 不开心。\n\n给定一...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ n \\in \\mathbb{Z} $, $ n \\geq 1 $. \nLet $ \\sigma \\in S_n $ be the identity permutation: $ \\sigma(i) = i $ for all $ i \\in \\{1, \\dots, n\\} $. \nLet $ \\mathcal{P} = \\{ (i,j) \\mid...",
"is_translate": false,
"language": "Formal"
}
]
}