QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 256 MB Puntuación total: 100

#1435. 一个排列问题

Estadísticas

Zenyk 有一个包含 $1$ 到 $n$ 的排列。他的任务是将该排列排序,并且他必须恰好交换每一对整数各一次。

你能帮他完成这个任务吗?

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 1000$)。第二行包含一个 $1$ 到 $n$ 之间的整数排列 $P$。

输出格式

如果无法将排列排序,输出 “no”。否则,输出 $\frac{n(n-1)}{2}$ 行,每行描述在对应步骤中需要交换的两个数值(而非下标)。

样例

样例输入 1

4
3 2 4 1

样例输出 1

1 2
4 1
1 3
2 3
2 4
3 4

样例输入 2

3
1 3 2

样例输出 2

1 3
3 2
1 2

样例输入 3

2
1 2

样例输出 3

no

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.