#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
int n;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
int r = 0;
for(int p = 1; p < n; p *= 2) {
for(int k = p; k >= 1; k /= 2) {
r++;
}
}
cout << r << "\n";
for(int p = 1; p < n; p *= 2) {
for(int k = p; k >= 1; k /= 2) {
for(int j = k % p; j <= n - 1 - k; j += 2*k) {
for(int i = 0; i <= k - 1; i++) {
if((i+j)/(p*2) == (i+j+k)/(p*2)) {
if(i + j + k + 1 <= n) {
cout << "CMPSWP R" << i + j+1 << " R" << i + j + k+1 << " ";
}
}
}
}
cout << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |