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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:26:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < str.size(); i++)
                    ^
input/code.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < coms.size(); i++)
                   ^

Code

#include <iostream>
#include <vector>
using namespace std;
int main()
{
string str;
cin >> str;
vector<int> coms;
bool loop = true;
char cor = 'Z';
while(loop)
{
if(str[0] > str[1] && str[0] < cor)
{
swap(str[0], str[1]);
coms.push_back(1);
}
loop = false;
for(int i = 0; i < str.size(); i++)
{
if(str[i] == cor)
{
while((int)str[i - 1] == (int)cor - 1 && i >= 0) {i--; cor--;}
if(cor != 'A')
loop = true;
break;
}
}
if(loop)
{
str = str[str.size() - 1] + str;
str.erase(str.begin() + str.size() - 1);
coms.push_back(2);
}
}
cout << coms.size() << endl;
for(int i = 0; i < coms.size(); i++)
{
cout << (coms[i] == 1 ? "SWAP" : "MOVE") << endl;
}
}

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
923
MOVE
MOVE
SWAP
MOVE
...

Test 3

Verdict: ACCEPTED

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
611
SWAP
MOVE
MOVE
SWAP
...

Test 4

Verdict: ACCEPTED

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
659
MOVE
SWAP
MOVE
SWAP
...

Test 5

Verdict: ACCEPTED

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
624
MOVE
SWAP
MOVE
SWAP
...