Task: | Merkkijono |
Sender: | Katajisto |
Submission time: | 2018-01-18 13:28:42 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 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 'bool order(std::string)': input/code.cpp:5:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 1; i < s.length(); i++) ^ input/code.cpp: In function 'std::string to(std::string)': input/code.cpp:16:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 1; i < s.length(); i++) ^
Code
#include<bits/stdc++.h> using namespace std; bool order(string s) { for(int i = 1; i < s.length(); i++) { if(s[i-1] > s[i]) return false; } return true; } string to(string s) { char last = s[s.length()-1]; char temp = s[0]; s[0] = last; for(int i = 1; i < s.length(); i++) { char tt = s[i]; s[i] = temp; temp = tt; } return s; } int main() { vector<string> move; string s; cin >> s; bool last = false; while(!order(s)) { if(s[s.length()-1] < s[0]) { move.push_back("MOVE"); s = to(s); } if(s[0] > s[1]) { move.push_back("SWAP"); char temp = s[0]; s[0] = s[1]; s[1] = temp; } else { if(last == false) { move.push_back("SWAP"); char temp = s[0]; s[0] = s[1]; s[1] = temp; last = true; } else { move.push_back("MOVE"); s = to(s); last = false; } } // cout << s << "\n"; } cout << move.size() << "\n"; for(string s : move) { cout << s << "\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) |