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

Code

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define N (1<<20)

ll t[N], V1[N], V2[N];
vector<int> v;

int main(){
	string s;
	cin >> s;
	char a = 'Z';
	--a;
	while(a != 'A'-1){ // max 26
		while(s[0] != a) {
			s = s[25] + s.substr(0, 25); // max 26
			v.push_back(1);
		}
		while(s[1] != a+1) { // max 26
			s = s[25] + s.substr(0, 25); // 1
			v.push_back(1);
			swap(s[0], s[1]);	// 1
			v.push_back(0);
		}
		--a;
	}
	cout << v.size() << "\n";
	for(int i : v){
		if(i) cout << "MOVE\n";
		else cout << "SWAP\n";
	}
}

Test details

Test 1

Verdict: ACCEPTED

input
ABCDEFGHIJKLMNOPQRSTUVWXYZ

correct output
0

user output
26
MOVE
MOVE
MOVE
MOVE
...

Test 2

Verdict: ACCEPTED

input
ZYXWVUTSRQPONMLKJIHGFEDCBA

correct output
923
MOVE
MOVE
SWAP
MOVE
...

user output
925
MOVE
MOVE
MOVE
MOVE
...

Test 3

Verdict: ACCEPTED

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
967
MOVE
MOVE
MOVE
MOVE
...

Test 4

Verdict: ACCEPTED

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
965
MOVE
MOVE
MOVE
MOVE
...

Test 5

Verdict: ACCEPTED

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
972
MOVE
MOVE
MOVE
MOVE
...