Task: | Merkkijono |
Sender: | Uolevi |
Submission time: | 2023-07-10 11:49:53 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
Code
#include<bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); int idx = 0; int c = 0; vector<string> ve; int co2 = 0; while (true) { if (s[idx % n] > s[(idx + 1) % n] && !(s[idx % n] == 'Z' && s[(idx+1) % n] == 'A')) { swap(s[idx % n], s[(idx + 1) % n]); ve.push_back("SWAP"); c = 0; } else { idx--; if (idx < 0) idx += n; ve.push_back("MOVE"); c++; } if (c >= 50 && s[idx % n] == 'A') break; co2++; } cout << ve.size() << "\n"; for (auto u : ve) cout << u << "\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
correct output |
---|
0 |
user output |
---|
52 MOVE MOVE MOVE MOVE ... |
Test 2
Verdict: ACCEPTED
input |
---|
ZYXWVUTSRQPONMLKJIHGFEDCBA |
correct output |
---|
923 MOVE MOVE SWAP MOVE ... |
user output |
---|
925 SWAP MOVE MOVE SWAP ... |
Test 3
Verdict: ACCEPTED
input |
---|
RPJMFWBHYQOTXUAENLDGZISCVK |
correct output |
---|
611 SWAP MOVE MOVE SWAP ... |
user output |
---|
709 SWAP MOVE MOVE SWAP ... |
Test 4
Verdict: ACCEPTED
input |
---|
GWJSPBHANMXYFLKIDORVUCEZQT |
correct output |
---|
659 MOVE SWAP MOVE SWAP ... |
user output |
---|
749 MOVE SWAP MOVE SWAP ... |
Test 5
Verdict: ACCEPTED
input |
---|
BJYNFLKEIUCZMQHRAXOGWPSDTV |
correct output |
---|
624 MOVE SWAP MOVE SWAP ... |
user output |
---|
676 MOVE SWAP MOVE SWAP ... |