Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++)
arr[i] = i + 1;
int i = 0;
while (i + 1 < n)
{
if (i + 1 < n)
{
swap(arr[i], arr[i + 1]);
}
i += 2;
}
if (i < n)
swap(arr[i], arr[i - 1]);
for (auto a : arr)
cout << a << " ";
cout << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1210 A. Smallest Permutation
- Contest
- Educational Round 1
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-07-14 15:34:02
- Judged At
- 2025-07-14 15:34:02
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB