Task: | Merkkijono |
Sender: | Leiska |
Submission time: | 2018-01-18 16:08: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:80:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<o0.size(); i++) { ^
Code
#include <bits/stdc++.h> using namespace std; string s0; string s; string c; vector<string> o; vector<string> o0; int r = 0; int maxk = 0; int counter=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 s) { if(c==s) return 1; return 0; } void search(int k) { if(k>maxk) { return; } if(r==1) return; string t=s; for(int i=0; i<2; i++) { if(o.size()>1 && o[o.size()-1] == o[o.size()-2] ) { counter++; if(o[o.size()-1]=="MOVE") { if(counter>=4) return; } else { if(counter>=2) return; } } else counter = 0; int c = check(s); if(c==1) { o0 = o; r = 1; } if(i==0) move(); else if (i==1) swap(); search(k+1); s=t; o.pop_back(); } } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> s0; s = s0; c = s; sort(c.begin(),c.end()); maxk = 50; search(0); cout << o0.size() << endl; for(int i=0; i<o0.size(); i++) { cout << o0[i] << endl; } } //ABCDEFGHIJKLMNOPQRSTUVWXYZ //STUHIJWVBCDEFGRXYZAKLMNOPQ
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) |