Task: | Merkkijono |
Sender: | ArktinenKarpalo |
Submission time: | 2018-01-18 13:22:54 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | TIME LIMIT EXCEEDED | -- | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
#4 | TIME LIMIT EXCEEDED | -- | details |
#5 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:12:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<s.size()-1; i++) ^
Code
#include <bits/stdc++.h> using namespace std; bool cnt; int ii; string s; vector<int> ans; int main() { cin >> s; for(int i=0; i<s.size()-1; i++) if(s[i]>s[i+1]) cnt=true; while(cnt) { cnt = false; while(s[0]!='A') { s = s.substr(s.size()-1, 1)+s; s.pop_back(); ans.push_back(0); } for(int i=s.size()-2; i>=0; i--) { if(s[i]>s[i+1]) { char cha = s[i]; while(s[0]!=cha) { s = s.substr(s.size()-1, 1)+s; s.pop_back(); ans.push_back(0); } cnt = true; } } if(cnt) { if(s[0]>s[1]) { char a = s[0]; s[0] = s[1]; s[1] = a; ans.push_back(1); } } } cout << ans.size() << "\n"; for(auto u:ans) if(u) cout << "SWAP\n"; else cout << "MOVE\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
ZYXWVUTSRQPONMLKJIHGFEDCBA |
correct output |
---|
923 MOVE MOVE SWAP MOVE ... |
user output |
---|
(empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
RPJMFWBHYQOTXUAENLDGZISCVK |
correct output |
---|
611 SWAP MOVE MOVE SWAP ... |
user output |
---|
(empty) |
Test 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
GWJSPBHANMXYFLKIDORVUCEZQT |
correct output |
---|
659 MOVE SWAP MOVE SWAP ... |
user output |
---|
(empty) |
Test 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
BJYNFLKEIUCZMQHRAXOGWPSDTV |
correct output |
---|
624 MOVE SWAP MOVE SWAP ... |
user output |
---|
(empty) |