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

Code

a = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
b = list(input())
c = []
n = 0
d = ["SWAP\n", "MOVE\n", "MOVE\nSWAP\n"]
for i in range(1, 27):
    x = b.index(a[-i])
    if x == 0:
        continue
    if x == 1:
        c.append(d[0])
        n+=1
        b[0], b[1] = b[1], b[0]
    else:
        c.append(d[2] * (26 - x))
        n += 2 * (26-x)
        c.append(d[1])
        n += 1
        b = [b[x]] + b[:i] + b[x+1:] + b[i:x]

print(n)
print("".join(c))
        

Test details

Test 1

Verdict: ACCEPTED

input
ABCDEFGHIJKLMNOPQRSTUVWXYZ

correct output
0

user output
78
MOVE
SWAP
MOVE
MOVE
...

Test 2

Verdict:

input
ZYXWVUTSRQPONMLKJIHGFEDCBA

correct output
923
MOVE
MOVE
SWAP
MOVE
...

user output
579
SWAP
MOVE
SWAP
MOVE
...

Test 3

Verdict:

input
RPJMFWBHYQOTXUAENLDGZISCVK

correct output
611
SWAP
MOVE
MOVE
SWAP
...

user output
364
MOVE
SWAP
MOVE
SWAP
...

Test 4

Verdict:

input
GWJSPBHANMXYFLKIDORVUCEZQT

correct output
659
MOVE
SWAP
MOVE
SWAP
...

user output
404
MOVE
SWAP
MOVE
SWAP
...

Test 5

Verdict:

input
BJYNFLKEIUCZMQHRAXOGWPSDTV

correct output
624
MOVE
SWAP
MOVE
SWAP
...

user output
380
MOVE
SWAP
MOVE
SWAP
...