# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
414536 | medmdg | MalnaRISC (COI21_malnarisc) | C++14 | 0 ms | 0 KiB |
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>
#define ll long long
#define endl "\n"
using namespace std;
void pr(pair<ll,ll> a){
cout<<"CMPSWP R"<<a.first<<" R"<<a.second<<" ";
}
int main() {
vector<pair<ll,ll> > B;
ll n;
cin>>n;
vector<vector<pair<ll,ll> > >ans;
bool a[n][n]={{false}};
for(int i=0;i<n;i++)
a[i][i]=true;
for(int f=0;f<n;f++){
bool h[n]={false};
if(f>0)
if(ans[ans.size()-1].size()==0)
break;
ans.push_back(B);
for(int i=0;i<n;i++){
if(h[i])
continue;
for(int j=0;j<n;j++){
if(h[j])
continue;
if(a[i][j]==false){
a[i][j]=true;
h[i]=true;
h[j]=true;
a[j][i]=true;
ans.push_back(make_pair(i+1,j+1));
break;
}
}
}
}
cout<<ans.size()<<endl;
for(int i=0;i<ans.size();i++){
for(int j=0;j<ans[i].size();j++){
pr(ans[i][j]);
}
cout<<endl;
}
}