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

Code

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    string input;

    cin >> input;

    vector<int> abNums;
    vector<int> nums;
    vector<int> moves;

    for(int i = 0; i < 26; i++)
    {
        abNums.push_back(i + 1);
        if(input[i] == 'A')
        {
            nums.push_back(1);
        }
        else if(input[i] == 'B')
        {
            nums.push_back(2);
        }
        else if(input[i] == 'C')
        {
            nums.push_back(3);
        }
        else if(input[i] == 'D')
        {
            nums.push_back(4);
        }
        else if(input[i] == 'E')
        {
            nums.push_back(5);
        }
        else if(input[i] == 'F')
        {
            nums.push_back(6);
        }
        else if(input[i] == 'G')
        {
            nums.push_back(7);
        }
        else if(input[i] == 'H')
        {
            nums.push_back(8);
        }
        else if(input[i] == 'I')
        {
            nums.push_back(9);
        }
        else if(input[i] == 'J')
        {
            nums.push_back(10);
        }
        else if(input[i] == 'K')
        {
            nums.push_back(11);
        }
        else if(input[i] == 'L')
        {
            nums.push_back(12);
        }
        else if(input[i] == 'M')
        {
            nums.push_back(13);
        }
        else if(input[i] == 'N')
        {
            nums.push_back(14);
        }
        else if(input[i] == 'O')
        {
            nums.push_back(15);
        }
        else if(input[i] == 'P')
        {
            nums.push_back(16);
        }
        else if(input[i] == 'Q')
        {
            nums.push_back(17);
        }
        else if(input[i] == 'R')
        {
            nums.push_back(18);
        }
        else if(input[i] == 'S')
        {
            nums.push_back(19);
        }
        else if(input[i] == 'T')
        {
            nums.push_back(20);
        }
        else if(input[i] == 'U')
        {
            nums.push_back(21);
        }
        else if(input[i] == 'V')
        {
            nums.push_back(22);
        }
        else if(input[i] == 'W')
        {
            nums.push_back(23);
        }
        else if(input[i] == 'X')
        {
            nums.push_back(24);
        }
        else if(input[i] == 'Y')
        {
            nums.push_back(25);
        }
        else if(input[i] == 'Z')
        {
            nums.push_back(26);
        }
    }

    while(nums != abNums)
    {
        if(nums[0] != nums[1] - 1 && nums[0] != (nums[nums.size() - 1] - 25))
        {
            if(nums[0] < nums[1])
            {
                nums.insert(nums.begin(), nums[nums.size() - 1]);
                nums.pop_back();
                moves.push_back(0);

                int a = nums[0];
                nums[0] = nums[1];
                nums[1] = a;

                moves.push_back(1);
            }
            else
            {
                int a = nums[0];
                nums[0] = nums[1];
                nums[1] = a;

                moves.push_back(1);
            }
        }
        else
        {
            nums.insert(nums.begin(), nums[nums.size() - 1]);
            nums.pop_back();
            moves.push_back(0);
        }
    }
    int moveCount = moves.size();
    cout << moveCount << endl;
    for(int i = 0; i < moveCount; i++)
    {
        if(moves[i] == 0)
        {
            cout << "MOVE" << endl;
        }
        else
        {
            cout << "SWAP" << endl;
        }
    }
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
ABCDEFGHIJKLMNOPQRSTUVWXYZ

correct output
0

user output
0

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)