大佬们为什么本地都可以,提交WA和RE参半?
查看原帖
大佬们为什么本地都可以,提交WA和RE参半?
117005
一指流沙楼主2022/3/20 13:23
本地连全0全1都试过,就是不知道哪里的问题?

代码如下:

lists = []
l, y = 0, 0
temp = input()
lists.append(len(temp))
for i in range(1, lists[0]):
    temp += input()

if temp[0] != '0':  # 若第一个为1则直接添加0
    lists.append(0)
for i in list(temp):
    if i == '0':
        l += 1
    else:
        y += 1
    if i == '0' and y > 0:
        lists.append(y)
        y = 0
    if i == '1' and l > 0:
        lists.append(l)
        l = 0

lists.append(l) if l > 0 else lists.append(y)
print(' '.join(list(map(str, lists))), end=' ')
2022/3/20 13:23
加载中...