CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:Jace
Submission time:2018-01-18 13:19:23 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2--details
#3--details
#4--details
#5--details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:44:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < ops.size(); i++){
                       ^

Code

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

void swap(vector<int> &ops, int* string){
    ops.push_back(1);
    int k = string[0];
    string[0] = string[1];
    string[1] = k;
}
void move(vector<int> &ops, int* string){
    ops.push_back(2);
    int k = string[25];
    for (int i = 25; i > 0; i--){
        string[i] = string[i-1];
    }
    string[0] = k;
}


int main(){
    vector<int> ops;
    bool finished = false;
    int string[26];
    for (int i = 0; i < 26; i++){
        string[i] = std::cin.get();
    }
    while (finished == false){
        while (string[0] < string[1]){
            move(ops, string);
        }
        swap(ops, string);
        finished = true;
        for (int i = 0; i < 26; i++){
            if (string[i]-65 != i){
                finished = false;
                break;
            }
        }
    }
    printf("%ld\n", ops.size());
    for (int i = 0; i < ops.size(); i++){
        if (ops[i] == 1){
            cout << "SWAP\n";
        } else {
            cout << "MOVE\n";
        }
    }

}

Test details

Test 1

Verdict: ACCEPTED

input
ABCDEFGHIJKLMNOPQRSTUVWXYZ

correct output
0

user output
50
MOVE
SWAP
MOVE
SWAP
...

Test 2

Verdict:

input
ZYXWVUTSRQPONMLKJIHGFEDCBA

correct output
923
MOVE
MOVE
SWAP
MOVE
...

user output
(empty)

Test 3

Verdict:

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
(empty)

Test 4

Verdict:

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
(empty)

Test 5

Verdict:

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
(empty)