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;
int N,a[105];
bool isSorted() {
for(int i=2;i<=N;i++)
if(a[i-1]>a[i])
return false;
return true;
}
int main() {
cin>>N;
int turn=1+N%2;
vector<string> rs;
for(int i=1;i<=N;i++)
a[i]=N-i+1;
while(!isSorted()) {
string str="";
for(int i=turn;i+1<=N;i+=2) {
str+="CMPSWP R"+to_string(i)+" R"+to_string(i+1)+" ";
if(a[i]>a[i+1])
swap(a[i],a[i+1]);
}
rs.push_back(str);
turn=3-turn;
}
cout<<rs.size()<<'\n';
for(string str:rs)
cout<<str<<'\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... |