Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split())
s = [0] * h
for _ in range(h):
    s[_] = input()

# print(s)
# print(s[1][1])

ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            drawable = False
            # check
            if hi >= 1:
                drawable = (s[hi-1][wi] == '#') | drawable
            
            if hi <= h-2:
                drawable = (s[hi+1][wi] == '#') | drawable
            
            if wi >= 1:
                drawable = (s[hi][wi-1] == '#') | drawable
            
            if wi <= w-2:
                drawable = (s[hi][wi+1] == '#') | drawable

            # if hi >= 1:
            #     if s[hi-1][wi] == 

            if not drawable:
                ok = False

print("Yes" if ok else "No")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [0] * w
for _ in range(h):
    s[_] = input()

# print(s)
# print(s[1][1])

ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            drawable = False
            # check
            if hi >= 1:
                drawable = (s[hi-1][wi] == '#') | drawable
            
            if hi <= h-2:
                drawable = (s[hi+1][wi] == '#') | drawable
            
            if wi >= 1:
                drawable = (s[hi][wi-1] == '#') | drawable
            
            if wi <= w-2:
                drawable = (s[hi][wi+1] == '#') | drawable

            # if hi >= 1:
            #     if s[hi-1][wi] == 

            if not drawable:
                ok = False

print("Yes" if ok else "No")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [0] * w
for _ in range(h):
    s[_] = [c for c in input()]

# print(s)
# print(s[1][1])

ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            drawable = False
            # check
            if hi >= 1:
                drawable = (s[hi-1][wi] == '#') | drawable
            
            if hi <= h-2:
                drawable = (s[hi+1][wi] == '#') | drawable
            
            if wi >= 1:
                drawable = (s[hi][wi-1] == '#') | drawable
            
            if wi <= w-2:
                drawable = (s[hi][wi+1] == '#') | drawable

            if not drawable:
                ok = False

print("Yes" if ok else "No")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [0] * w
for _ in range(h):
    s[_] = [c for c in input()]

# print(s)
# print(s[1][1])

ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            drawable = False
            # check
            if hi > 0:
                drawable = (s[hi-1][wi] == '#') | drawable
            
            if hi < h-1:
                drawable = (s[hi+1][wi] == '#') | drawable
            
            if wi > 0:
                drawable = (s[hi][wi-1] == '#') | drawable
            
            if wi < w-1:
                drawable = (s[hi][wi+1] == '#') | drawable

            if not drawable:
                ok = False

print("Yes" if ok else "No")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [0] * w
for _ in range(h):
    s[_] = [c for c in input()]

# print(s)
# print(s[1][1])

ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            drawable = False
            # check
            if hi > 0:
                drawable = (s[hi-1][wi] == '#') | drawable
            
            if hi < h-1:
                drawable = (s[hi+1][wi] == '#') | drawable
            
            if wi > 0:
                drawable = (s[hi][wi-1] == '#') | drawable
            
            if wi < w-1:
                drawable = (s[hi][wi+1] == '#') | drawable

            if not drawable:
                ok = False
                break

print("Yes" if ok else "No")