QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#395911 | #3117. Cyclic antimonotonic permutations | Heart_Blue | 100 ✓ | 263ms | 7836kb | C++23 | 1.0kb | 2024-04-22 04:42:00 | 2024-04-22 04:42:00 |
Judging History
answer
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e6 + 10;
int a[N];
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n;
while (scanf("%d", &n) != EOF)
{
if (n == 0) break;
a[1] = 1;
for (int i = 2; i <= n; i++)
{
a[i] = i;
if (i & 1) swap(a[i], a[i - 2]);
else swap(a[i], a[i - 1]);
}
for (int i = 1; i <= n; i++)
printf("%d%c", a[i], " \n"[i == n]);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 263ms
memory: 7836kb
input:
3 4 5 6 7 8 9 10 11 12 686 44 292 17 1000000 95211 8763 21 28 31 46429 25 215 18 55368 3059 577 27 40 36 48 4736 349 34 983 19 821 7172 39 16 22 665382 33 386 20 32 999999 26 9690 13 42 47 6926 5027 91530 38 803655 15 723171 35 50 45 29 7540 576450 46 24 393 37 4362 55782 23 14 41 49 43 935 52567 30...
output:
3 1 2 3 1 4 2 3 1 5 2 4 3 1 5 2 6 4 3 1 5 2 7 4 6 3 1 5 2 7 4 8 6 3 1 5 2 7 4 9 6 8 3 1 5 2 7 4 9 6 10 8 3 1 5 2 7 4 9 6 11 8 10 3 1 5 2 7 4 9 6 11 8 12 10 3 1 5 2 7 4 9 6 11 8 13 10 15 12 17 14 19 16 21 18 23 20 25 22 27 24 29 26 31 28 33 30 35 32 37 34 39 36 41 38 43 40 45 42 47 44 49 46 51 48 53 ...
result:
ok correct (80 test cases)