304214: CF804E. The same permutation
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
The same permutation
题意翻译
题目描述 给出一个长度为$n$,元素互不相同的序列$a_i$,有一种交换操作:将数列中的$a_i$与$a_j$交换($i \neq j$),易知本质不同的交换操作有$\frac{n(n-1)}{2}$种。现在请你合理安排这$\frac{n(n-1)}{2}$个交换操作的顺序,使得按照你给出的顺序对序列进行交换过后的序列与原序列相同。 输入格式 一行一个整数$n(1 \leq n \leq 1000)$表示序列长度。因为序列元素并不重要,所以你可以认为$a_i=i$ 输入格式 如果存在一种顺序满足题意,那么第一行输出$Yes$,接着输出$\frac{n(n-1)}{2}$行,其中第$i$行输出两个正整数$a,b$表示第$i$个进行的交换操作,中间用一个空格隔开。如果不存在任何一种顺序满足题意,只需输出一行$No$。题目描述
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.输入输出格式
输入格式
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} $ .
输出格式
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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF804E/c0359cb82752ff2b028ccb729bac55ece58968d2.png) 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.
输入输出样例
输入样例 #1
3
输出样例 #1
NO
输入样例 #2
1
输出样例 #2
YES