Problem p03361 (python)

Fixed submission:
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

H, W = map(int, input().split())
s = [None]*H
for i in range(H):
    s[i] = input()
    # print(s[i])
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            #print(i, j)
            if (i != 0 and s[i-1][j] == '#') or(i != H-1 and s[i+1][j] == '#')or(j != 0 and s[i][j-1] == '#') or(j != W-1 and s[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (i != 0 and tmp[i-1][j] == '#')or(i != h-1 and tmp[i+1][j] == '#') or(j != 0 and tmp[i][j-1] == '#')or(j != w-1 and tmp[i][j+1] == '#'):
                continue

            print('No')
            exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h-1):
    for j in range(w-1):
        if tmp[i][j] == '#':
            if (i != 0 and tmp[i-1][j] == '#')or(i+1 < h and tmp[i+1][j] == '#') or(j != 0 and tmp[i][j-1] == '#')or(j+1 < w and tmp[i][j+1] == '#'):
                continue

            print('No')
            exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (i != 0 and tmp[i-1][j] == '#')or(i+1 < h and tmp[i+1][j] == '#') or(j != 0 and tmp[i][j-1] == '#')or(j+1 < w and tmp[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (i != 0 and tmp[i-1][j] == '#')or(i != h-1 and tmp[i+1][j] == '#') or(j != 0 and tmp[i][j-1] == '#')or(j != w-1 and tmp[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (i-1 >= 0 and tmp[i-1][j] == '#')or(i < h-1 and tmp[i+1][j] == '#') or(j-1 >= 0 and tmp[i][j-1] == '#')or(j < w-1 and tmp[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (i-1 >= 0 and tmp[i-1][j] == '#')or(i+1 <= h-1 and tmp[i+1][j] == '#') or(j-1 >= 0 and tmp[i][j-1] == '#')or(j+1 <= w-1 and tmp[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (i-1 >= 0 and tmp[i-1][j] == '#')or(i+1 <= h-1 and tmp[i+1][j] == '#') or(tmp[i][j-1] == '#' and j-1 >= 0)or(j+1 <= w-1 and tmp[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (tmp[i-1][j] == '#' and i-1 >= 0)or(tmp[i+1][j] == '#' and i+1 <= h-1) or(tmp[i][j-1] == '#' and j-1 >= 0)or(tmp[i][j+1] == '#' and j+1 <= w-1):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h-1):
    for j in range(w-1):
        if tmp[i][j] == '#':
            if (tmp[i-1][j] == '#' and i-1 >= 0)or(tmp[i+1][j] == '#' and i+1 <= h-1) or(tmp[i][j-1] == '#' and j-1 >= 0)or(tmp[i][j+1] == '#' and j+1 <= w-1):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h-1):
    for j in range(w-1):

        if tmp[i][j] == '#':
            if (tmp[i-1][j] == '#' and i-1 >= 0)or(tmp[i+1][j] == '#' and i+1 <= h-1) or(tmp[i][j-1] == '#' and j-1 >= 0)or(tmp[i][j+1] == '#' and j+i <= w-1):
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h-1):
    for j in range(w-1):
        if tmp[i][j] == '#':
            if (tmp[i-1][j] == '#' and i-1 >= 0)or(tmp[i+1][j] == '#' and i+1 <= h-1) or(tmp[i][j-1] == '#' and j-1 >= 0)or(tmp[i][j+1] == '#' and j+1 <= w-1):
                continue
            else:
                print('No')
                exit()
print('Yes')