Task: | Merkkijono |
Sender: | Olli |
Submission time: | 2018-01-18 13:10:55 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | RUNTIME ERROR | 0.95 s | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
#4 | RUNTIME ERROR | 0.96 s | details |
#5 | RUNTIME ERROR | 0.96 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:52:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < oper.size(); ++i) { ^ input/code.cpp:28:6: warning: unused variable 'moves' [-Wunused-variable] int moves = 0; ^
Code
#include <iostream> #include <vector> #include <deque> using namespace std; vector<string> oper; deque<char> q; bool inOrder() { for(deque<char>::iterator it = q.begin() + 1; it != q.end(); ++it) { char a = *it; char b = *(it - 1); if((int) b > (int) a) { return false; } } return true; } int main() { string s; cin >> s; int n = 26; int moves = 0; for(int i = 0; i < n; ++i) { q.insert(q.end(), s[i]); } while(!inOrder()) { //cout << s << "\n"; char a = *q.begin(); char b = *(q.begin() + 1); if((int) a > b) { oper.push_back("SWAP"); q.erase(q.begin()); q.erase(q.begin()); q.insert(q.begin(), a); q.insert(q.begin(), b); } char c = *(q.end() - 1); q.erase(q.end() - 1); q.insert(q.begin(), c); oper.push_back("MOVE"); } cout << oper.size() << "\n"; for(int i = 0; i < oper.size(); ++i) { cout << oper[i] << "\n"; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: RUNTIME ERROR
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: RUNTIME ERROR
input |
---|
GWJSPBHANMXYFLKIDORVUCEZQT |
correct output |
---|
659 MOVE SWAP MOVE SWAP ... |
user output |
---|
(empty) |
Test 5
Verdict: RUNTIME ERROR
input |
---|
BJYNFLKEIUCZMQHRAXOGWPSDTV |
correct output |
---|
624 MOVE SWAP MOVE SWAP ... |
user output |
---|
(empty) |