tigee @ 2023-09-01 20:56:40
d1 = str(input()) an = str(len(d1)) n = 1 for i in range(2, len(d1) + 1): d1 += str(input()) if d1[0] == '1': an += " 0"
for i in range(0, len(d1) - 1): if d1[i] != d1[i + 1]: an += " " + str(n) n = 1 else: n += 1 an += " " + str(n) print(an)
by tigee @ 2023-09-01 20:58:14
第一次发帖子不知道有没有成功。
by tigee @ 2023-09-01 20:58:54
d1 = str(input())
an = str(len(d1))
n = 1
for i in range(2, len(d1) + 1):
d1 += str(input())
if d1[0] == '1':
an += " 0"
for i in range(0, len(d1) - 1):
if d1[i] != d1[i + 1]:
an += " " + str(n)
n = 1
else:
n += 1
an += " " + str(n)
print(an)
by _Fog_ @ 2023-09-01 21:08:21
奇怪的是,我给你的input()后面每一个都加了.strip(), 它就过了???
d1 = input().strip()
an = str(len(d1))
n = 1
for i in range(2, len(d1) + 1):
d1 += input().strip()
if d1[0] == '1':
an += " 0"
for i in range(0, len(d1) - 1):
if d1[i] != d1[i + 1]:
an += " " + str(n)
n = 1
else:
n += 1
an += " " + str(n)
print(an)
by _Fog_ @ 2023-09-01 21:08:40
https://www.luogu.com.cn/record/123506004
by _Fog_ @ 2023-09-01 21:09:18
我也是第一次发python题解呢(hehe)