Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
 
flag = False
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if (j-1 >= 0 and s[i][j-1] == '.') and (j+1 < W and s[i][j+1] == '.') and (i-1 >= 0 and s[i-1][j] == '.') and (i+1 < H and s[i+1][j] == '.'):
                print('No')
                flag = True
                break
    if flag:
        break
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [['.']*(w+2)] + [['.']+list(input())+['.'] for _ in range(w)] + [['.']*(w+2)]
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '.': continue
        if s[i-1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' and s[i+1][j] == '.':
            print('No')
            exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [['.']*(w+2)] + [['.']+list(input())+['.'] for _ in range(w)] + [['.']*(w+2)]
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           if s[i-1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' and s[i+1][j] == '.':
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [['.']*(w+2)] + [['.']+list(input())+['.'] for _ in range(w)] + [['.']*(w+2)]
a = True
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           if s[i-1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.' and s[i+1][j] == '.':
                a = False
                break
    if not a:
        break
if a ==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
#96
h, w = map(int, input().split())
s = [['.']*(w+2)] + [['.']+list(input())+['.'] for _ in range(w)] + [['.']*(w+2)]
a = True
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           up = s[i-1][j]
           left = s[i][j-1]
           right = s[i][j+1]
           down = s[i+1][j]
           if up == '.' and left == '.' and right == '.' and down == '.':
                a = False
                break
    if not a:
        break
if a ==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [['.']*(w+2)]
s = s + [['.']+list(input())+['.'] for _ in range(w)]
s = s + [['.']*(w+2)]
a = True
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           up = s[i-1][j]
           left = s[i][j-1]
           right = s[i][j+1]
           down = s[i+1][j]
           if up == '.' and left == '.' and right == '.' and down == '.':
                a = False
                break
    if not a:
        break
if a ==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [['.']*(w+2)]
s = s + [['.']+list(input())+['.'] for _ in range(w)]
s = s + [['.']*(w+2)]
a = True
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           up = s[i-1][j]
           left = s[i][j-1]
           right = s[i][j+1]
           down = s[i+1][j]
           if up == '.' and left == '.' and right == '.' and down == '.':
               a = False
if a ==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [['.']*(w+2)]
s = s + [['.']+list(input())+[','] for _ in range(w)]
s = s + [['.']*(w+2)]
a = True
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           up = s[i-1][j]
           left = s[i][j-1]
           right = s[i][j+1]
           down = s[i+1][j]
           if up == '.' and left == '.' and right == '.' and down == '.':
               a = False
if a ==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [['.']*(w+2)]
s = s + [['.']+list(input())+[','] for _ in range(w)]
s = s + [['.']*(w+2)]
print(s)
a = True
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           up = s[i-1][j]
           left = s[i][j-1]
           right = s[i][j+1]
           down = s[i+1][j]
           if up == '.' and left == '.' and right == '.' and down == '.':
               a = False
if a ==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [['.']*(w+2)]
s = s + [['.']+list(input())+[','] for _ in range(w)]
s = s + [['.']*(w+2)]
for i in range(1, w+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
           up = s[i-1][j]
           left = s[i][j-1]
           right = s[i][j+1]
           down = s[i+1][j]
           if up == '.' and left == '.' and right == '.' and down == '.':
               print('No')
               exit()
print('Yes')