CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:Kuha
Submission time:2018-01-18 12:30:57 +0200
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.04 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.05 sdetails
#5ACCEPTED0.03 sdetails

Code

#include <bits/stdc++.h>
#define ll long long

using namespace std;
string ans;
int cord (string s) {
    int ord = 0;
    int a = 0;
    for (int i = 0; i < 26; i++) {
        if (s[i] == 'A') a = i;
    }
    ord = 1;
    while (ord < 26 && s[(a + ord) % 26] == ans[ord]) ord++;
    ord--;
    return ord;
}

int main () {
    string s;
    cin>>s;
    ans = s;
    sort(ans.begin(), ans.end());
    vector<int> lol;
    while (ans != s) {
        if (s[0] > s[1] && s[0] > ans[cord(s)] && s[1] > ans[cord(s)]) {
            swap(s[0], s[1]);
            lol.push_back(1);
        } else {
            char c = s[25];
            s.pop_back();
            s = c + s;
            lol.push_back(2);
        }
        //if (lol.size() < 10) cout<<s<<" "<<cord(s)<<endl;
    }
    cout<<lol.size()<<endl;
    for (int i : lol) {
        if (i == 1) cout<<"SWAP"<<endl;
        else cout<<"MOVE"<<endl;
    }
}

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
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
...