CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:ArktinenKarpalo
Submission time:2018-01-18 14:44:50 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#20.05 sdetails
#30.04 sdetails
#40.04 sdetails
#50.04 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1; i<s.size(); i++) {
                 ^
input/code.cpp:31:11: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    if((!aa&&s[i]>s[i+1]||aa&&s[i]<s[i+1])&&s[i+1]!='A'&&s[i]!='A') {
           ^
input/code.cpp:16:8: warning: variable 'bt' set but not used [-Wunused-but-set-variable]
   bool bt = true;
        ^

Code

#include <bits/stdc++.h>
#define ll long long

using namespace std;

string s;
vector<int> ans;
int ii=0;

int main() {
	cin >> s;
	while(true) {
		ii++;
		if(ii>20)
			break;
		bool bt = true;
		bool ccc = true;
		for(int i=1; i<s.size(); i++) {
			if(s[i]<s[i-1]) {
				ccc = false;
				break;
			}
		}
		if(s[0]=='A'&&ccc) {
			break;
		}
		bool aa = false;
		for(int i=s.size()-2; i>=0; i--) {
			if(s[i]=='A')
				aa=true;
			if((!aa&&s[i]>s[i+1]||aa&&s[i]<s[i+1])&&s[i+1]!='A'&&s[i]!='A') {
				bt = false;
				char cha = s[i];
				while(s[0]!=cha) {
					s = s.substr(s.size()-1, 1)+s;
					s.pop_back();
					ans.push_back(0);
				}
				char a = s[0];
				s[0] = s[1];
				s[1] = a;
				ans.push_back(1);
				break;
			}
		}
			if(s[0]!='A') {	
					s = s.substr(s.size()-1, 1)+s;
					s.pop_back();
					ans.push_back(0);
			}
		cout << s <<endl;
	}
	cout << ans.size() << "\n";
	for(auto u:ans)
		if(u)
			cout <<"SWAP\n";
		else
			cout <<"MOVE\n";

}

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
DBCAZYXWVUTSRQPONMLKJIHGFE
GEFDBCAZYXWVUTSRQPONMLKJIH
JHIGEFDBCAZYXWVUTSRQPONMLK
MKLJHIGEFDBCAZYXWVUTSRQPON
PNOMKLJHIGEFDBCAZYXWVUTSRQ
...

Test 3

Verdict:

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
CKVRPJMFWBHYQOTXUAENLDGZIS
GIZSCKVRPJMFWBHYQOTXUAENLD
NDLGIZSCKVRPJMFWBHYQOTXUAE
OXTUAENDLGIZSCKVRPJMFWBHYQ
HQYOXTUAENDLGIZSCKVRPJMFWB
...

Test 4

Verdict:

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
EQZTGWJSPBHANMXYFLKIDORVUC
VCUEQZTGWJSPBHANMXYFLKIDOR
KDIORVCUEQZTGWJSPBHANMXYFL
XFYLKDIORVCUEQZTGWJSPBHANM
AMNXFYLKDIORVCUEQZTGWJSPBH
...

Test 5

Verdict:

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
PDSTVBJYNFLKEIUCZMQHRAXOGW
XGOWPDSTVBJYNFLKEIUCZMQHRA
MHQRAXGOWPDSTVBJYNFLKEIUCZ
ICUZMHQRAXGOWPDSTVBJYNFLKE
LEKICUZMHQRAXGOWPDSTVBJYNF
...