[python]求助,本地可以,评测RE了,是什么问题?

P1319 压缩技术

starkxx2022 @ 2023-11-23 11:15:41

li = input().split(" ")
N = int(li[0])
print_str = ""
for i in range(1,len(li)):
    if li[i] == "0":
        continue
    if i % 2 == 0:
        for j in range(int(li[i])):
            print_str += "1"
    else:
        for k in range(int(li[i])):
            print_str += "0"

for m in range(len(print_str)):
    if m % N == 0 and m != 0:
        print()
    print(print_str[m],end="")

by yang_ziyang @ 2023-12-29 21:29:09

注意地一行是li = input().split()


by Winds_Land @ 2024-01-29 15:54:16

lst = list(map(int, input().split()))
# 标记当前输出字符
key = 0
# cnt 用来统计当前字符连续输出次数, idx 是 lst 中的索引,lst[idx] 对应当前字符需要重复的次数
cnt,idx = 0,1
for i in range(lst[0]):
    for j in range(lst[0]):
        if cnt == lst[idx]:
            key ^= 1
            cnt = 0
            idx += 1
        print(key,end='')
        cnt += 1
    print()

|