#include <bits/stdc++.h>
using namespace std;
using ops = vector<vector<pair<int, int>>>;
ops faz_morro(int n) {
if (n == 0) return {};
ops ans(1);
int m = (1 << (n-1));
for (int i = 0; i < m; ++i)
ans.back().emplace_back(i, i + m);
auto xss = faz_morro(n-1);
for (auto &xs: xss) {
ans.emplace_back();
for (auto [a, b]: xs) {
ans.back().emplace_back(a, b);
ans.back().emplace_back(a + m, b + m);
}
}
return ans;
}
ops solve(int n) {
if (n == 0) return {};
auto xss = solve(n-1);
ops ans;
for (auto &xs: xss) {
ans.emplace_back();
for (auto [a, b]: xs)
ans.back().emplace_back(a, b);
int m = 1 << (n-1);
for (auto [a, b]: xs)
ans.back().emplace_back(b + m, a + m);
}
auto yss = faz_morro(n);
for (auto &ys: yss) {
ans.emplace_back();
for (auto y: ys)
ans.back().push_back(y);
}
return ans;
}
int main() {
int n;
cin >> n;
ops ans = solve(__lg(n));
cout << ans.size() << "\n";
for (auto &xs: ans) {
for (auto [a, b]: xs)
cout << "CMPSWP R" << a + 1 << " R" << b + 1 << " ";
cout << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 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 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 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 |
Incorrect |
0 ms |
348 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
not sorted |
2 |
Halted |
0 ms |
0 KB |
- |