Task: | Merkkijono |
Sender: | FSMnArmosta |
Submission time: | 2018-01-18 13:24:59 +0200 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.07 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.06 s | details |
#5 | ACCEPTED | 0.04 s | details |
Code
#include <bits/stdc++.h> using namespace std; const int n = 26; int main(){ char chars[n]; char c2[n]; for(int i = 0; i < n; i++){ char c; cin >> c; chars[i] = c; c2[i] = c; } int moves = 0; bool done = false; while(!done){ done = true; for(int i = 0; i < n-1; i++){ if(c2[i] > c2[i+1]){ int t = c2[i]; c2[i] = c2[i+1]; c2[i+1] = t; done = false; moves++; } } } cout << (moves * (n+1)) << endl; done = false; while(!done){ done = true; for(int i = 0; i < n-1; i++){ if(chars[i] > chars[i+1]){ for(int t = 0; t < n-i; t++) cout << "MOVE" << endl; cout << "SWAP" << endl; for(int t = n-i; t < n; t++) cout << "MOVE" << endl; int t = chars[i]; chars[i] = chars[i+1]; chars[i+1] = t; done = false; } } } }
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 |
---|
8775 MOVE MOVE MOVE MOVE ... |
Test 3
Verdict: ACCEPTED
input |
---|
RPJMFWBHYQOTXUAENLDGZISCVK |
correct output |
---|
611 SWAP MOVE MOVE SWAP ... |
user output |
---|
4617 MOVE MOVE MOVE MOVE ... |
Test 4
Verdict: ACCEPTED
input |
---|
GWJSPBHANMXYFLKIDORVUCEZQT |
correct output |
---|
659 MOVE SWAP MOVE SWAP ... |
user output |
---|
3861 MOVE MOVE MOVE MOVE ... |
Test 5
Verdict: ACCEPTED
input |
---|
BJYNFLKEIUCZMQHRAXOGWPSDTV |
correct output |
---|
624 MOVE SWAP MOVE SWAP ... |
user output |
---|
3564 MOVE MOVE MOVE MOVE ... |