CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:tuomask
Submission time:2018-01-18 12:56:20 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1--details
#2--details
#3--details
#4--details
#5--details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:25:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true;
                  ^

Code

#include <bits/stdc++.h>
using namespace std;
string s;
vector<string> si;
int pos=0;
int get(int i) {
	i += pos;
	i = i % s.length();
	return i;
}
int main() {
	cin >> s;
	bool jatka=true;
	while (jatka) {
		if (s[get(0)] > s[get(1)]) {
			swap(s[get(0)], s[get(1)]);
			si.push_back("SWAP");
		}
		si.push_back("MOVE");
		pos--;
		if (pos < 0) pos = s.length()-1;
		
		string oik="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		jatka = false;
		for (int i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true;
	}
	cout << si.size() << "\n";
	for (auto it=si.begin(); it!=si.end(); it++) cout << *it << "\n";
}

Test details

Test 1

Verdict:

input
ABCDEFGHIJKLMNOPQRSTUVWXYZ

correct output
0

user output
(empty)

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)