Submission #434931

#TimeUsernameProblemLanguageResultExecution timeMemory
434931dqhungdlMalnaRISC (COI21_malnarisc)C++17
76.41 / 100
2 ms332 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...