A2oj.com,运行时错误
问题#22
最近,我正在从a2oj解决以下问题
我的解决办法是:
# to check for adjacent items in a 2d array
# just check the item next to it, below it and diagonal to it
t = int(input())
o = []
while t >= 1:
n,m = map(int,input().split())
c = 0
li = []
uni = []
while c < m:
li.append(map(int,input().split()))
c += 1
r = 0
co = 0
while r < n-1:
c = 0
while c < m-1:
# if the place is empty skip checking
if li[r][c] == -1:
c += 1
continue
# if university is already counted also skip checking it
if li[r][c] in uni:
c += 1
continue
if li[r][c] == li[r][c+1]:
uni.append(li[r][c])
co += 1
if li[r][c] == li[r+1][c+1]:
uni.append(li[r][c])
co += 1
if li[r][c] == li[r+1][c]:
uni.append(li[r][c])
co += 1
c += 1
r += 1
o.append(co)
t -= 1
for w in o:
print(w)
这段代码对于给定的示例非常有效。但是当我把它提交给a2oj在线评委时,我得到了运行时错误。我也不知道为什么我会出错。你能告诉我如何知道a2oj平台中的错误,或者你能帮我处理代码吗
目前没有回答
相关问题 更多 >
编程相关推荐