Task: | Merkkijono |
Sender: | Leiska |
Submission time: | 2018-01-18 13:34:04 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | WRONG ANSWER | 0.04 s | details |
#3 | WRONG ANSWER | 0.05 s | details |
#4 | WRONG ANSWER | 0.03 s | details |
#5 | WRONG ANSWER | 0.04 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:61:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<o.size(); i++) { ^
Code
#include <bits/stdc++.h> using namespace std; string s; string s0; vector<string> o; int r = 0; int maxk = 0; void swap() { o.push_back("SWAP"); char t = s[0]; s[0] = s[1]; s[1] = t; } void move() { o.push_back("MOVE"); char t = s[s.size()-1]; s.erase(s.size()-1,1); s.insert(s.begin(),t); } int check() { string c = s; sort(c.begin(), c.end()); if(c==s) return 1; return 0; } void search(int k) { int c = check(); if(c == 1) { r = 1; return; } if(k==maxk) { //s=s0; //o.erase(o.begin(),o.end()); return; } if(r==1) return; for(int i=0; i<2; i++) { if(i==0) swap(); else if (i==1) move(); search(k+1); } } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> s; s0=s; maxk = 5; search(0); cout << o.size() << endl; for(int i=0; i<o.size(); i++) { cout << o[i] << endl; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: WRONG ANSWER
input |
---|
ZYXWVUTSRQPONMLKJIHGFEDCBA |
correct output |
---|
923 MOVE MOVE SWAP MOVE ... |
user output |
---|
62 SWAP SWAP SWAP SWAP ... |
Test 3
Verdict: WRONG ANSWER
input |
---|
RPJMFWBHYQOTXUAENLDGZISCVK |
correct output |
---|
611 SWAP MOVE MOVE SWAP ... |
user output |
---|
62 SWAP SWAP SWAP SWAP ... |
Test 4
Verdict: WRONG ANSWER
input |
---|
GWJSPBHANMXYFLKIDORVUCEZQT |
correct output |
---|
659 MOVE SWAP MOVE SWAP ... |
user output |
---|
62 SWAP SWAP SWAP SWAP ... |
Test 5
Verdict: WRONG ANSWER
input |
---|
BJYNFLKEIUCZMQHRAXOGWPSDTV |
correct output |
---|
624 MOVE SWAP MOVE SWAP ... |
user output |
---|
62 SWAP SWAP SWAP SWAP ... |