#include <bits/stdc++.h>
using namespace std;
int sort(vector<int> inds, vector<vector<pair<int, int>>> &ans) {
if (inds.size() == 1) {
return 0;
}
vector<int> inds1, inds2;
for (int i = 0; i < (int)inds.size(); ++i) {
if (i % 2 == 0) {
inds1.push_back(inds[i]);
} else {
inds2.push_back(inds[i]);
}
}
int pos = max(sort(inds1, ans), sort(inds2, ans));
for (int i = 0; i < ((int)inds.size() + 1) / 2; ++i) {
if ((int)ans.size() <= pos) {
ans.push_back({});
}
for (int j = i; j + 1 < (int)inds.size(); j += 2) {
ans[pos].emplace_back(inds[j], inds[j + 1]);
}
pos++;
}
return pos;
}
void solve() {
int n;
cin >> n;
vector<int> a(n);
iota(a.begin(), a.end(), 1);
vector<vector<pair<int, int>>> ans;
sort(a, ans);
cout << ans.size() << '\n';
for (auto v : ans) {
for (auto p : v) {
cout << "CMPSWP R" << p.first << " R" << p.second;
if (p != v.back()) {
cout << ' ';
}
}
cout << '\n';
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Partially correct |