CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:Yytsi
Submission time:2018-01-18 13:03:22 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#20.94 sdetails
#30.93 sdetails
#40.90 sdetails
#50.96 sdetails

Code

#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<int> lst;
vector<int> oper;

bool sorted() {
	for (int i = 0; i < 25; i++) {
		if (lst[i] > lst[i + 1]) return false;
	}
	return true;
}

int main()
{
	string s; cin >> s;
	for (int i = 0; i < (int)s.size(); i++) {
		char c = s[i];
		lst.push_back((int)c - 65);
	}
	
	int k = 0;
	
	while (!sorted()) {
		k++;
		if (lst[0] > lst[1]) {
			int z = lst[1]; lst[1] = lst[0]; lst[0] = z;
			oper.push_back(0);
		} else {
			int last = lst[25];
			lst.pop_back();
			lst.insert(lst.begin(), last);
			oper.push_back(1);
		}
	}
	
	cout << k << "\n";
	for (int i = 0; i < (int)oper.size(); i++) {
		if (lst[i] == 0) cout << "SWAP\n";
		else cout << "MOVE\n";
	}
	
	
	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)