#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
const int inf = 1e16;
const int N = 10;
vector< vector<array<int, 2> > > ans[N];
void f(int l, int r, int depth){
if(l == r) return;
int m = (l + r)/2;
for(int i = l; i <= m; i++){
vector<array<int, 2> > op;
int st = i;
for(int j = m+1; j <= r; j++){
op.pb({st, j});
st++;
if(st > m) st = l;
}
ans[depth].pb(op);
}
f(l, m, depth + 1);
f(m+1, r, depth + 1);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n;
cin>>n;
f(0, n-1, 0);
int anssz = 0;
for(int i = 0; i < N; i++){
//cout<<"depth = "<<i<<endl;
int cnt = 0;
vector<int> vis(n, 1);
for(auto itr: ans[i]){
//cout<<cnt<<" nolu vector"<<endl;
for(auto itr2: itr){
if(!vis[itr2[0]] && !vis[itr2[1]]){
vis[itr2[0]] = vis[itr2[1]] = 1;
}
else{
cnt++;
vis.assign(n, 0);
vis[itr2[0]] = vis[itr2[1]] = 1;
}
}
}
anssz += cnt;
}
bool start = 0;
cout<<anssz<<endl;
for(int i = 0; i < N; i++){
vector<int> vis(n, 1);
for(auto itr: ans[i]){
for(auto itr2: itr){
if(!vis[itr2[0]] && !vis[itr2[1]]){
vis[itr2[0]] = vis[itr2[1]] = 1;
start = 1;
cout<<"CMPSWP R"<<itr2[0]+1<<" R"<<itr2[1]+1<<" ";
}
else{
if(start) cout<<endl;
start = 1;
vis.assign(n, 0);
vis[itr2[0]] = vis[itr2[1]] = 1;
cout<<"CMPSWP R"<<itr2[0]+1<<" R"<<itr2[1]+1<<" ";
}
}
}
vis.clear();
}
cout<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
336 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
336 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
336 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
592 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
592 KB |
Partially correct |