Xuywuk1221 @ 2024-07-31 20:42:23
为什么提交之后全是RE啊, 请大佬帮忙看一下
str=input()
istr=x.split(" ")
for i in range(len(istr)):
istr[i]=int(istr[i])
N=istr[0]
t = 0
zoo=0;
for i in range(N):
for j in range(N):
if(istr[t+1]==0):
t+=1
zoo=1 if zoo==0 else 0
print(t)
print(zoo,end="")
istr[t+1]-=1
print()
by Jack1024 @ 2024-09-01 14:40:58
可以参考一下下面的代码?
str_ = input().split(' ')[:-1]
long_ = int(str_[0])
before = ''
for i in range(1, len(str_)):
if int(str_[i])>0:
if i % 2 == 1:
before = before + int(str_[i]) * '0'
else:
before = before + int(str_[i]) * '1'
for i in range(len(before)):
if i % long_ == 0 and i>0:
print()
print(before[i], end='')
另外,提醒一下,洛谷的输入最后是有一个空格的,split之后还要去掉最后一个空格。
ps.别用关键字作变量!