Submission #5655560


Source Code Expand

Copy
s = input()

a = ''
ss = ''
b = ''
for i in range(len(s)):
    ss += s[-1-i]
    if s[i]!='x':
        a+=s[i]
        b = s[i]+b

if a!=b:
    print(-1)
else:
    i = 0
    ans = 0
    while s!=ss:
        if i>=len(s):
            ans += len(ss)-i
            break
        elif i>= len(ss):
            ans += len(s)-i
            break
        if s[i]!=ss[i]:
            if s[i]=='x':
                ss = ss[:i]+'x'+ss[i:]
            else:
                s = s[:i]+'x'+s[i:]
            ans += 1
        i+=1
    print(ans//2)

Submission Info

Submission Time
Task C - Inserting 'x'
User psmf1
Language Python3 (3.4.3)
Score 0
Code Size 568 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0 / 400 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt
Case Name Status Exec Time Memory
0_00.txt 17 ms 3064 KB
0_01.txt 17 ms 3064 KB
0_02.txt 17 ms 3064 KB
0_03.txt 17 ms 3064 KB
1_00.txt 18 ms 3064 KB
1_01.txt 17 ms 3064 KB
1_02.txt 17 ms 3064 KB
1_03.txt 17 ms 3064 KB
1_04.txt 18 ms 3064 KB
1_05.txt 17 ms 3064 KB
1_06.txt 345 ms 3700 KB
1_07.txt 47 ms 3188 KB
1_08.txt 334 ms 3700 KB
1_09.txt 46 ms 3188 KB
1_10.txt
1_11.txt
1_12.txt 1517 ms 3844 KB
1_13.txt 47 ms 3188 KB
1_14.txt 976 ms 3720 KB
1_15.txt 294 ms 3596 KB
1_16.txt 45 ms 3188 KB
1_17.txt 842 ms 3736 KB
1_18.txt 46 ms 3188 KB
1_19.txt 1257 ms 3696 KB
1_20.txt 47 ms 3444 KB
1_21.txt 1788 ms 3848 KB
1_22.txt 70 ms 3316 KB
1_23.txt 1590 ms 4028 KB
1_24.txt 88 ms 3444 KB
1_25.txt 1433 ms 4040 KB
1_26.txt 129 ms 3444 KB
1_27.txt 328 ms 3700 KB
1_28.txt 341 ms 3572 KB