CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:Ilmari2000
Submission time:2018-01-18 15:46:41 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#20.04 sdetails
#30.04 sdetails
#40.04 sdetails
#50.04 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:37: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;

	while(loop)
	{
		loop = false;
		int m = 0;
		for(int i = 0; i < 25; i++)
		{
			if(str[i] > str[i + 1])
			{
				for(int j = 0; j < 25 - m; j++)
					coms.push_back(2);
		
				swap(str[i], str[i + 1]);
				loop = true;
				coms.push_back(1);
				m = 0;
			}
			else
				m++;
		}
	}

	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:

input
ZYXWVUTSRQPONMLKJIHGFEDCBA

correct output
923
MOVE
MOVE
SWAP
MOVE
...

user output
8450
MOVE
MOVE
MOVE
MOVE
...

Test 3

Verdict:

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
4314
MOVE
MOVE
MOVE
MOVE
...

Test 4

Verdict:

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
3593
MOVE
MOVE
MOVE
MOVE
...

Test 5

Verdict:

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
3285
MOVE
MOVE
MOVE
MOVE
...