CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:SeveriK
Submission time:2018-01-18 16:15:28 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:139:17: error: stray '\302' in program
                 nums[1] = a;
                 ^
input/code.cpp:139:17: error: stray '\240' in program
input/code.cpp:147:17: error: stray '\302' in program
                 nums[1] = a;
                 ^
input/code.cpp:147:17: error: stray '\240' in program
input/code.cpp: In function 'int main()':
input/code.cpp:133:53: error: no matching function for call to 'std::vector<int>::insert(int, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&)'
                 nums.insert(0, nums[nums.size() - 1]);
                                                     ^
In file included from /usr/include/c++/5/vector:69:0,
                 from input/code.cpp:5:
/usr/include/c++/5/bits/vector.tcc:107:5: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cx...

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;

    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)
        {
            if(nums[0] < nums[1])
            {
                nums.insert(0, nums[nums.size() - 1]);
                nums.pop_back();
                cout << "MOVE" << "\n";

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

                cout << "SWAP" << "\n";
            }
            else
            {
                int a = nums[0];
                nums[0] = nums[1];
                nums[1] = a;

                cout << "SWAP" << "\n";
            }
        }
    }

    return 0;
}