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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:24:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (ll i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true;
                 ^
input/code.cpp:32:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (ll i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true;
                 ^
input/code.cpp:16:6: warning: unused variable 'i' [-Wunused-variable]
  int i=0;
      ^

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string oik="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string s;
vector<int> si;
ll pos=0;
ll get(ll i) {
	ll a = (i - pos);
	if (a<0) a=s.length()-abs(a);
	return a;
}
int main() {
	cin >> s;
	bool jatka=true;
	int i=0;
	while (jatka) {
		if (s[get(0)] > s[get(1)] && s[get(1)]!='A') {
			swap(s[get(0)], s[get(1)]);
			si.push_back(0);
		}
		
		jatka = false;
		for (ll i=0; i<s.length() && !jatka; i++) if (s[get(i)] != oik[i]) jatka=true;
		if (!jatka) break;
		
		si.push_back(1);
		pos++;
		pos = pos % s.length();
		
		jatka = false;
		for (ll 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)==0 ? "SWAP" : "MOVE") << "\n";
}

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