This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |