CSES - Datatähti 2018 loppu - Results
Submission details
Task:Merkkijono
Sender:Kisse
Submission time:2018-01-18 14:57:20 +0200
Language:Python3
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.07 sdetails
#20.07 sdetails
#30.08 sdetails
#40.07 sdetails
#50.07 sdetails

Code

ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
String = input()
MoveList = []
I = 0
while 42:
	Start = String.find("A")
	Seg = "A"
	J = 0
	while len(Seg) < 26:
		J += 1
		if Seg + String[(Start + J) % 26] in ABC:
			Seg = Seg + String[(Start + J) % 26]
		else:
			break
	if len(Seg) == 26:
		break
	if (ABC.index(String[I]) - ABC.index(String[I + 1]) > 0):
		String = String.replace(String[I:I + 2], String[I + 1] + String[I])
		MoveList.append("SWAP")
	print("B", String)
	MoveList.append("MOVE")
	I += 1
print(len(MoveList))
for L in MoveList:
	print(L)

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
B YZXWVUTSRQPONMLKJIHGFEDCBA
B YXZWVUTSRQPONMLKJIHGFEDCBA
B YXWZVUTSRQPONMLKJIHGFEDCBA
B YXWVZUTSRQPONMLKJIHGFEDCBA
B YXWVUZTSRQPONMLKJIHGFEDCBA
...

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    if (ABC.index(String[I]) - ABC.index(String[I + 1]) > 0):
IndexError: string index out of range

Test 3

Verdict:

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
B PRJMFWBHYQOTXUAENLDGZISCVK
B PJRMFWBHYQOTXUAENLDGZISCVK
B PJMRFWBHYQOTXUAENLDGZISCVK
B PJMFRWBHYQOTXUAENLDGZISCVK
B PJMFRWBHYQOTXUAENLDGZISCVK
...

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    if (ABC.index(String[I]) - ABC.index(String[I + 1]) > 0):
IndexError: string index out of range

Test 4

Verdict:

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
B GWJSPBHANMXYFLKIDORVUCEZQT
B GJWSPBHANMXYFLKIDORVUCEZQT
B GJSWPBHANMXYFLKIDORVUCEZQT
B GJSPWBHANMXYFLKIDORVUCEZQT
B GJSPBWHANMXYFLKIDORVUCEZQT
...

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    if (ABC.index(String[I]) - ABC.index(String[I + 1]) > 0):
IndexError: string index out of range

Test 5

Verdict:

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
B BJYNFLKEIUCZMQHRAXOGWPSDTV
B BJYNFLKEIUCZMQHRAXOGWPSDTV
B BJNYFLKEIUCZMQHRAXOGWPSDTV
B BJNFYLKEIUCZMQHRAXOGWPSDTV
B BJNFLYKEIUCZMQHRAXOGWPSDTV
...

Error:
Traceback (most recent call last):
  File "input/code.py", line 17, in <module>
    if (ABC.index(String[I]) - ABC.index(String[I + 1]) > 0):
IndexError: string index out of range