在idle上测试测试结果是一样的,但是过不了

P1320 压缩技术(续集版)

wufei555 @ 2022-01-12 14:18:14

l = input()

n = len(l)

i = 0

while i<n-1:

l += input()
i += 1

l = list(l)

print(n,end = " ")

a = 0;b = 0

if l[0] == "1":

print(0,end = " ")

for j in range(len(l)):

if j != len(l)-1:
    if l[j] == "0" :
        a += 1
        if l[j+1] == "1":
            print(a,end = " ")
            a = 0
    elif l[j] == "1":
        b += 1
        if l [j+1] == "0":
            print(b,end = " ")
            b = 0
else:
    if l[j] == "0" :
        a += 1
        print(a)
    else:
        b += 1
        print(b)

if l[n-1] == "0":

print(0)

|