Task: | Merkkijono |
Sender: | Jace |
Submission time: | 2018-01-18 13:46:50 +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.05 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.05 s | details |
Code
#include <iostream> #include <vector> #include <cstdio> #include <string.h> using namespace std; int main(){ vector<bool> ops; bool finished = false; int string[27]; int k; for (int i = 0; i < 26; i++){ string[i] = std::cin.get()-65; } while (finished == false){ if (string[0] < string[1] or string[1] == 0){ ops.push_back(false); k = string[25]; memmove(string+1, string, 25*sizeof(int)); string[0] = k; } else { if (string[1] != 0) { ops.push_back(true); k = string[0]; string[0] = string[1]; string[1] = k; } } finished = true; for (int i = 0; i < 26; i++){ if (string[i] != i){ finished = false; break; } } } printf("%ld\n", ops.size()); for (unsigned int i = 0; i < ops.size(); i++){ if (ops[i]){ cout << "SWAP\n"; } else { cout << "MOVE\n"; } } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABCDEFGHIJKLMNOPQRSTUVWXYZ |
correct output |
---|
0 |
user output |
---|
26 MOVE MOVE MOVE MOVE ... |
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 ... |