Problem p03361 (python)

Fixed submission:
N,M = map(int, input().split())
boards = [None] * N
passed = [[False] * M for i in range(N)]
for i in range(N):
    boards[i] = list(input())
for i in range(N):
    for j in range(M):
        if boards[i][j] == '#':
            if ((i < N - 1 and boards[i+1][j] == '#') or 
                (i >= 1 and boards [i-1][j] == '#') or 
                (j < M - 1 and boards[i][j+1] == '#') or
                (j >= 1 and boards[i][j-1] == '#')):
                    continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):

a,b=map(int,input().split())
x=[0,0,-1,1]
y=[-1,1,0,0]
d=[]
for i in range(b):
    d.append(list(input()))
    
    
for i in range(b):
    for j in range(a):
    
        if d[i][j] == '#':
        
            check=0
            
            for xv,yv in zip(x,y):
                if 0 <= xv + j < a  and 0 <= yv + i < b:
                    if d[i+yv][j+xv] == "#":
                        check=1
                        break
        
            if check==0:
                print("No")
                exit()
            
                        
print("Yes")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
x=[0,0,-1,1]
y=[-1,1,0,0]
d=[]
for i in range(b):
    d.append(list(input()))
    
result="Yes"
for i in range(b):
    for j in range(a):
        if d[i][j] == '#':
            check=0
            for xv,yv in zip(x,y):
                if 0 <= xv + j < a  and 0 <= yv + i < b:
                    if d[i+yv][j+xv] == '#':
                        check=1
                        break
        
            if check==0:
                result="No"
                break
            
                    
print(result)

Buggy submission (verdict: Runtime Error):

a,b=map(int,input().split())
x=[0,0,-1,1]
y=[-1,1,0,0]
d=[[0]*a for x in range(b)]
for i in range(b):
    d[i]=list(input())
    
result="Yes"

for i in range(b):
    for j in range(a):
        if d[i][j] == '#':
            check=0
            for xv,yv in zip(x,y):
                if 0 <= xv + j < a  and 0 <= yv + i < b:
                    if d[i+yv][j+xv] == '#':
                        check=1
                        #break
        
            if check==0:
                result="No"
                #break
            
                        
print(result)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
x=[0,0,-1,1]
y=[-1,1,0,0]
d=[[0]*a for x in range(b)]
for i in range(b):
    d[i]=list(input())
    
result="Yes"

for i in range(b):
    for j in range(a):
        if d[i][j] == '#':
            check=0
            for xv,yv in zip(x,y):
                if 0 <= xv + j < a  and 0 <= yv + i < b:
                    if d[i+yv][j+xv] == '#':
                        check=1
                        break
            if check==0:
                result="No"
                        
print(result)

Buggy submission (verdict: Runtime Error):

a,b=map(int,input().split())
x=[0,0,-1,1]
y=[-1,1,0,0]
d=[[0]*a for x in range(b)]
for i in range(b):
    d[i]=list(input())
    
result="Yes"

for i in range(b):
    for j in range(a):
        if d[i][j] == '#':
            check=0
            for xv,yv in zip(x,y):
                if 0 <= xv + j < a  and 0 <= yv + i < b:
                    if d[i+yv][j+xv] == '#':
                        check=1
                        break
            if check==0:
                result="No"
                        
print(result)