Problem p03361 (python)

Fixed submission:
def main() -> None:
    H, W = map(int, input().split())
    s = ['0' + input() + '0' for _ in range(H)]
    s.insert(0, '0' * (W + 2))
    s.append('0' * (W + 2))
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            # print(s[i][j])
            if s[i][j] == "#":
                if s[i+1][j] == "#" or s[i-1][j] == "#" or s[i][j+1] == "#" or s[i][j-1] == "#":
                    continue
                else:
                    print("No")
                    exit()
    print("Yes")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main() -> None:
    H, W = map(int, input().split())
    s = ['0' + input() + '0' for _ in range(H)]
    s.insert(0, '0' * (W + 2))
    s.append('0' * (W + 2))
    num = 0
    # for v in s:
    #     print(v)
    for i in range(1, W + 1):
        for j in range(1, H + 1):
            # print(s[j][i])
            if s[i][j] == "#":
                num += 1
                if s[i+1][j] == "#" or s[i-1][j] == "#" or s[i][j+1] == "#" or s[i][j-1] == "#":
                    continue
                else:
                    print("No")
                    exit()
    if num == 0:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main() -> None:
    H, W = map(int, input().split())
    s = ['0' + input() + '0' for _ in range(H)]
    s.insert(0, '0' * (W + 2))
    s.append('0' * (W + 2))
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if s[j][i] == "#":
                if s[j+1][i] == "#" or s[j-1][i] == "#" or s[j][i+1] == "#" or s[j][i-1] == "#":
                    continue
                else:
                    print("No")
                    exit()
    print("Yes")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main() -> None:
    H, W = map(int, input().split())
    s = ['0' + input() + '0' for _ in range(H)]
    s.insert(0, '0' * (W + 2))
    s.append('0' * (W + 2))
    print(s)
    for v in s:
        print(v)
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if s[j][i] == "#":
                if s[j+1][i] == "#" or s[j-1][i] == "#" or s[j][i+1] == "#" or s[j][i-1] == "#":
                    continue
                else:
                    print("No")
                    exit()
    print("Yes")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main() -> None:
    H, W = map(int, input().split())
    s = ['0' + input() + '0' for _ in range(W)]
    s.insert(0, '0' * (W + 2))
    s.append('0' * (W + 2))
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if s[j][i] == "#":
                if s[j+1][i] == "#" or s[j-1][i] == "#" or s[j][i+1] == "#" or s[j][i-1] == "#":
                    continue
                else:
                    print("No")
                    exit()
    print("Yes")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main() -> None:
    H, W = map(int, input().split())
    s = ['0' + input() + '0' for _ in range(W)]
    s.insert(0, '0' * (W + 2))
    s.append('0' * (W + 2))
    for i in range(1, H):
        for j in range(1, W):
            if s[j][i] == "#":
                if s[j+1][i] == "#" or s[j-1][i] == "#" or s[j][i+1] == "#" or s[j][i-1] == "#":
                    pass
                else:
                    print("No")
                    exit()
    print("Yes")


if __name__ == '__main__':
    main()