#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;
#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
const int SIZE = 130;
int n, sz;
int a[SIZE];
int m;
bool vs[SIZE][SIZE];
vector<pair<int, int>> ans[SIZE];
void add(int x, int y) {
for (int i = 1;; i++) if (vs[i][x] == 0 && vs[i][y] == 0) {
vs[i][x] = vs[i][y] = 1;
m = max(m, i);
ans[i].pb(x, y);
return;
}
}
void bmerge(int l, int r, bool rev) {
if (l == r) return;
int mid = (l + r) / 2, len = mid - l + 1;
FOR (i, l, mid) {
if (a[i] == 0) {
if (rev == 0) swap(a[i], a[i + len]);
} else if (a[i + len] == 0) {
if (rev) swap(a[i], a[i + len]);
} else {
if (rev) add(a[i + len], a[i]);
else add(a[i], a[i + len]);
}
}
bmerge(l, mid, rev);
bmerge(mid + 1, r, rev);
}
void bsort(int l, int r, bool rev) {
if (l == r) return;
int mid = (l + r) / 2;
bsort(l, mid, 0);
bsort(mid + 1, r, 1);
bmerge(l, r, rev);
}
void solve() {
cin >> n;
sz = 1;
while (sz < n) sz <<= 1;
iota(a + 1, a + n + 1, 1);
bsort(1, sz, 0);
cout << m << '\n';
FOR (i, 1, m) {
for (auto [x, y] : ans[i]) cout << "CMPSWP" << ' ' << "R" << x << ' ' << "R" << y << ' ';
cout << '\n';
}
}
int main() {
Waimai;
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |