CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:ArktinenKarpalo
Submission time:2018-01-18 14:49:43 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#20.05 sdetails
#30.06 sdetails
#40.04 sdetails
#50.05 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 << 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
85
MOVE
MOVE
MOVE
SWAP
...

Test 3

Verdict:

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
95
MOVE
MOVE
SWAP
MOVE
...

Test 4

Verdict:

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
99
MOVE
MOVE
MOVE
SWAP
...

Test 5

Verdict:

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
98
MOVE
MOVE
MOVE
MOVE
...