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

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
	string s;
	cin >> s;

	vector<int> a(26);
	for (unsigned int i = 0; i < a.size(); i++)
		a[i] = (int)s[i] - 65;

	vector<int> b = a;
	sort(b.begin(), b.end());

	int k = 0;
	int h;
	vector<int> m;
	while(b != a) {
		k++;
		if (a[0] > a[1] && a[1] != 0) {
			m.push_back(0);
			h = a[1];
			a.erase(a.begin() + 1);
			a.insert(a.begin(), h);
		} else {
			m.push_back(1);
			a.insert(a.begin(), a.back());
			a.pop_back();	
		}
		if (k > 1000000)
			return 1;
	}

	cout << k << endl;
	for (unsigned int i = 0; i < m.size(); i++)
		cout << ((m[i])?"MOVE":"SWAP") << endl;
	return 0;
}

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