Task: | Merkkijono |
Sender: | tuomask |
Submission time: | 2018-01-18 15:09:28 +0200 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.04 s | details |
#4 | ACCEPTED | 0.04 s | details |
#5 | ACCEPTED | 0.04 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:24:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (ll i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true; ^ input/code.cpp:32:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (ll i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true; ^ input/code.cpp:16:6: warning: unused variable 'i' [-Wunused-variable] int i=0; ^
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; string oik="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string s; vector<int> si; ll pos=0; ll get(ll i) { ll a = (i - pos); if (a<0) a=s.length()-abs(a); return a; } int main() { cin >> s; bool jatka=true; int i=0; while (jatka) { if (s[get(0)] > s[get(1)] && s[get(1)]!='A') { swap(s[get(0)], s[get(1)]); si.push_back(0); } jatka = false; for (ll i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true; if (!jatka) break; si.push_back(1); pos++; pos = pos % s.length(); jatka = false; for (ll i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true; } cout << si.size() << "\n"; for (auto it=si.begin(); it!=si.end(); it++) cout << ((*it)==0 ? "SWAP" : "MOVE") << "\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: ACCEPTED
input |
---|
ZYXWVUTSRQPONMLKJIHGFEDCBA |
correct output |
---|
923 MOVE MOVE SWAP MOVE ... |
user output |
---|
899 SWAP MOVE MOVE MOVE ... |
Test 3
Verdict: ACCEPTED
input |
---|
RPJMFWBHYQOTXUAENLDGZISCVK |
correct output |
---|
611 SWAP MOVE MOVE SWAP ... |
user output |
---|
593 SWAP MOVE MOVE SWAP ... |
Test 4
Verdict: ACCEPTED
input |
---|
GWJSPBHANMXYFLKIDORVUCEZQT |
correct output |
---|
659 MOVE SWAP MOVE SWAP ... |
user output |
---|
675 MOVE SWAP MOVE SWAP ... |
Test 5
Verdict: ACCEPTED
input |
---|
BJYNFLKEIUCZMQHRAXOGWPSDTV |
correct output |
---|
624 MOVE SWAP MOVE SWAP ... |
user output |
---|
720 MOVE SWAP MOVE SWAP ... |