A. Smallest Permutation
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 0.5 s
Memory Limit: 256.0 MB
Description
You are given a positive integer \(N\) which is greater than 1.
Your task is to construct the lexicographically smallest permutation \(P\) of integers from \(1\) to \(N\) such that:
A permutation \(A\) is lexicographically smaller than a permutation \(B\) if at the first position where they differ, the element in \(A\) is smaller than in \(B\).
For example:
1 3 2
is lexicographically smaller than2 1 3
because1 < 2
.
Among all valid permutations where \(P_i \ne i\), you must choose the lexicographically smallest one.
Input
The first line contains an integer \(T\) \((1 \le T \le 99)\) — the number of test cases.
Each of the next \(T\) lines contains a single integer \(N\) \((2 \le N \le 100)\).
Output
For each test case, print:
- A line containing \(N\) space-separated integers — the required permutation
Sample
Input | Output |
---|---|
|
|
Third test case
:
The resulting permutation is:
2 1 4 3
This satisfies:
\(P_1 = 2 ≠ 1\)
\(P_2 = 1 ≠ 2\)
\(P_3 = 4 ≠ 3\)
\(P_4 = 3 ≠ 4\)
Among all valid permutations, this is the lexicographically smallest one.
So, the output is:
2 1 4 3
Educational Round 1
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 6
- Start at
- 2025-07-14 15:30
- End at
- 2025-07-14 18:00
- Duration
- 2.5 hour(s)
- Host
- Partic.
- 127