Problem:


Score: 300 points

Problem Statement

We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).

Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= ..

However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.

Determine if square1001 can achieve his objective.  

Constraints

H is an integer between 1 and 50 (inclusive).

W is an integer between 1 and 50 (inclusive).

For every (i, j) (1 \leq i \leq H, 1 \leq j \leq W), s_{i, j} is # or ..

Input

Input is given from Standard Input in the following format:

H W
s_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W}
s_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W}
  :   :
s_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W}

Output

If square1001 can achieve his objective, print Yes; if he cannot, print No.

Sample Input 1

3 3
.#.
###
.#.

Sample Output 1

Yes

One possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.

Sample Input 2

5 5
#.#.#
.#.#.
#.#.#
.#.#.
#.#.#

Sample Output 2

No

square1001 cannot achieve his objective here.

Sample Input 3

11 11
...#####...
.##.....##.
#..##.##..#
#..##.##..#
#.........#
#...###...#
.#########.
.#.#.#.#.#.
##.#.#.#.##
..##.#.##..
.##..#..##.

Sample Output 3

Yes



Sample input:
3 3
.#.
###
.#.


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())  # 入力
s = [0 for i in range(h)]
for i in range(h):
    s[i] = list(input())


flag = False


def hantei(i, j):
    if i < 0 or i > h-1 or j < 0 or j > w-1:
        return False
    elif True:
        if s[i][j] == '#':
            return True
    else:
        #print(s[i][j])
        return False


def hantei2(i,j):
    if hantei(i-1, j) or hantei(i+1, j) or hantei(i, j-1) or hantei(i, j+1):
        return True
    else:
        return  False


for i in range(0, h):
    for j in range(0, w):
        if s[i][j] == '#':
            flag = hantei2(i,j)
        

if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())  # 入力

s = [0 for i in range(h)]
for i in range(h):
    s[i] = list(input())


flag = False


def hantei(i, j):
    if i < 0 or i > h-1 or j < 0 or j > w-1:
        return False
    elif True:
        if s[i][j] == '#':
            return True
    else:
        #print(s[i][j])
        return False


def hantei2(i,j):
    if hantei(i-1, j) or hantei(i+1, j) or hantei(i, j-1) or hantei(i, j+1):
        return True
    else:
        return  False


for i in range(0, h):
    for j in range(0, w):
        if s[i][j] == '#':
            flag = hantei2(i,j)
        

if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
d = list(map(int,input().split()))
at = []
at.append(["."]*(d[1]+2))
for i in range(d[0]):
  at.append(list(input()))
  at[i+1].insert(0,".")
  at[i+1].insert(d[1],".")
at.append(["."]*(d[1]+2))
l = [[1,0],[0,1],[-1,0],[0,-1]]
re = True
op = False
ppp = True
def ao(k, re,op,l,ppp,d):
  for a in range(1,d[0]):
    for b in range(1,d[1]):
      for dx,dy in l:
        if k[a][b] =="#" and k[a+dx][b+dy] ==".":
          re = False
        if k[a][b] =="#" and k[a+dx][b+dy] =="#":
          op = True
      if op == True:
        re = True
      if re == False:
        ppp = False
      op = False
      re = True
  if ppp == False:
    return False
  else:
    return True

if ao(at,re,op,l,ppp,d) == True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
h, w = list(map(int, input().split()))
s = [input() for i in range(h)]


judge = "Yes"
for i in range(h-1):
    for j in range(w-1):
        if i > 0 and j > 0 and i < h and j < w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i == 0 and j == 0 and i < h and j < w:
            if s[i][j] != "#" and s[i][j] != s[i+1][j] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i == 0 and j > 0 and i < h and j == w:
            if s[i][j] != "#" and s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1]:
                judge = "No"
                break
        elif i > 0 and j == 0 and i == h and j < w:
            if s[i][j] != "#" and s[i][j] != s[i-1][j] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i > 0 and j > 0 and i == h and j == w:
            if s[i][j] != "#" and s[i][j] != s[i-1][j] and s[i][j] != s[i][j-1]:
                judge = "No"
                break
        elif i > 0 and j > 0 and i == h and j < w:
            if s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i > 0 and j > 0 and i < h and j == w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1]:
                judge = "No"
                break
        elif i > 0 and j == 0 and i < h and j < w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i == 0 and j > 0 and i < h and j < w:
            if s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break

print(judge)

Submission status: Wrong Answer

Solution code:
h, w = list(map(int, input().split()))
s = [input() for i in range(h)]


judge = "Yes"
for i in range(h-1):
    for j in range(w-1):
        if i > 0 and j > 0 and i < h and j < w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i == 0 and j == 0 and i < h and j < w:
            if s[i][j] != "." and s[i][j] != s[i+1][j] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i == 0 and j > 0 and i < h and j == w:
            if s[i][j] != "." and s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1]:
                judge = "No"
                break
        elif i > 0 and j == 0 and i == h and j < w:
            if s[i][j] != "." and s[i][j] != s[i-1][j] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i > 0 and j > 0 and i == h and j == w:
            if s[i][j] != "." and s[i][j] != s[i-1][j] and s[i][j] != s[i][j-1]:
                judge = "No"
                break
        elif i > 0 and j > 0 and i == h and j < w:
            if s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i > 0 and j > 0 and i < h and j == w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1]:
                judge = "No"
                break
        elif i > 0 and j == 0 and i < h and j < w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i == 0 and j > 0 and i < h and j < w:
            if s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break

print(judge)

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W = map(int, raw_input().split())

S = np.zeros((H, W))

for i in range(H):
    tmp = list(raw_input())
    for j in range(W):
        if tmp[j] == "#":
            S[i, j] = 1
        else:
            S[i, j] = 0

an = [-1, 1]
d_flag = 1

for i in range(H):
    for j in range(W):
        if S[i, j] == 1:
            flag = 0
            if i>1:
                a1 = S[i-1, j]
            else:
                a1 = S[i+1, j]
            if j>1:
                a2 = S[i, j-1]
            else:
                a2 = S[i, j+1]
            if i<H-1:
                a3 = S[i+1, j]
            else:
                a3 = S[i-1, j]
            if j>W-1:
                a4 = S[i, j+1]
            else:
                a4 = S[i, j-1]
            if a1+a2+a3+a4 == 0:
                d_flag = 0
                
if d_flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s = input().rstrip().split()
h = int(s[0])
w = int(s[1])

table = []

for i in range(h):
  t = input()
  line = list(t)
  table.append(line)

flg = 0

h_edge = h-1
w_edge = w-1

for i in range(h):
  for j in range(w):
    if(table[i][j] == "#"):
      table[i][j] == "/"
      if(i == 0 and j == 0):
        if(table[i][j+1] == "." and table[i+1][j] == "."):
          flg = 1
      elif(i == 0 and j != w_edge):
        if(table[i][j+1] == "." and table[i+1][j] == "." and table[i][j-1] == "."):
          flg = 1
        table[i][j+1] == "/"
        table[i+1][j] == "/"
      elif(j == 0 and i != h_edge):
        if(table[i][j+1] == "." and table[i+1][j] == "." and table[i-1][j] == "."):
          flg = 1
        table[i][j+1] == "/"
        table[i+1][j] == "/"
      elif(i == h_edge and j == w_edge):
        if(table[i-1][j] == "." and table[i][j-1] == "."):
          flg = 1
      elif(i == h_edge):
        if(table[i][j+1] == "." and table[i][j-1] == "." and table[i-1][j] == "."):
          flg = 1
        table[i][j+1] = "/"
      elif(j == w_edge):
        if(table[i+1][j] == "." and table[i][j-1] == "." and table[i-1][j] == "."):
          flg = 1
        table[i+1][j] = "/"
      else:
        if(table[i][j+1] == "." and table[i+1][j] == "." and table[i][j-1] == "." and table[i-1][j] == "."):
          flg = 1
        table[i][j+1] = "/"
        table[i+1][j] = "/"

      if(flg == 1):
        break
  else:
    continue
  break

if(flg==0):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import math

h, w = map(int, input().split())
canvas = []
flag = True

for i in range(h):
    x = list(map(list, input().split()))
    canvas.append(x)
# canvas[h][0][w]
# 黒く塗った所は@で表す
for i in range(h):
    for j in range(w):
        if canvas[i][0][j] == "#":
            if j-1 >= 0:
                # 左
                try:
                    if canvas[i][0][j-1] == "#" or canvas[i][0][j-1] == "@":
                        canvas[i][0][j-1] = "@"
                        canvas[i][0][j] = "@"
                except Exception as e:
                    pass
                try:
                    if canvas[i][0][j+1] == "#" or canvas[i][0][j+1] == "@":
                        canvas[i][0][j+1] = "@"
                        canvas[i][0][j] = "@"
                except Exception as e:
                    pass
            if i-1 >= 0:
                # 上
                try:
                    if canvas[i-1][0][j] == "#" or canvas[i-1][0][j] == "@":
                        canvas[i-1][0][j] = "@"
                        canvas[i][0][j] = "@"
                except Exception as e:
                    pass
                # 下
                try:
                    if canvas[i+1][0][j] == "#" or canvas[i+1][0][j] == "@":
                        canvas[i+1][0][j] = "@"
                        canvas[i][0][j] = "@"
                except Exception as e:
                    pass

for i in range(h):
    for j in range(w):
        if canvas[i][0][j] == "#":
            flag = False
            break
    if flag == False:
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())

T=0
if H==1 & W==1:
	print("Yes")
	T=1


D=0
Numlist = []
for i in range(H):
	D+=10
	I=0
	RawList = []
	RawList = list(input())

	for j in range(W):
		CheckNum = RawList[j]
		I+=1

		if CheckNum == "#":
			Numlist.append(D+I)

N=0
for k in range(len(Numlist)):
	A = Numlist[k]
#	print(A)

	OK=0

	if (A+1) in Numlist:
		OK+=1
	if (A-1) in Numlist:
		OK+=1
	if (A+10) in Numlist:
		OK+=1
	if (A-10) in Numlist:
		OK+=1

	if OK == 0 and T==0:
		print("No")
		N=1
		break
#	print(OK)

if N==0 and T==0:
	print("Yes")

Submission status: Wrong Answer

Solution code:
h, w = list(map(int, input().split()))
s = [input() for i in range(h)]


judge = "Yes"
for i in range(h-1):
    for j in range(w-1):
        if i > 0 and j > 0 and i < h and j < w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i > 0 and j > 0 and i == h and j < w:
            if s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i > 0 and j > 0 and i < h and j == w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1]:
                judge = "No"
                break
        elif i > 0 and j == 0 and i < h and j < w:
            if s[i][j] != s[i-1][j] and s[i][j] != s[i+1][j] and s[i][j] != s[i][j+1]:
                judge = "No"
                break
        elif i == 0 and j > 0 and i < h and j < w:
            if s[i][j] != s[i+1][j] and s[i][j] != s[i][j-1] and s[i][j] != s[i][j+1]:
                judge = "No"
                break

print(judge)

Submission status: Wrong Answer

Solution code:
h, w = (int(i) for i in input().split())
list = []

for i in range(h):
	list.append([])
	row = input()
	for j in range(w):
		element = row[j]
		list[i].append(element == '#')

def all_check(h, w, list):
	for i in range(h):
		for j in range(w):
			if not check(i, j, h, w, list):
				return False
			else:
				return True

def check(i, j, h, w,list):
	if not list[i][j]:
		return True
	else:
		subcheck(i, j, h, w, list)

def subcheck(i, j, h, w, list):
	if i > 0 and list[i-1][j]:
		return True
	if i < h-1 and list[i+1][j]:
		return True
	if j > 0 and list[i][j-1]:
		return True
	if j < w-1 and list[i][j+1]:
		return True

if all_check(h, w, list):
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
# 方針：黒く塗られるべきマスの隣（縦or横）に、同様のマスがあれば塗れる→Yes
# 逆に、黒く塗られるべきマスに接していない、黒く塗られるべきマスがあると、達成は不可能→No

# 行数・列数の入力(Row, Column)
R, C = list(map(int, input().split(" ")))
print(R, C)

# Want map = 設計図、Can map = 塗れるかのマップ
want_map = []
can_map = []

for r in range(R):
    # 一行ずつ、両マップを更新
    want_map.append(list(input()))
    can_map.append(["?"] * C)
#    print("Want Map: {}".format(want_map))

    for c in range(C):
        if can_map[r][c] != "feasible":
            if want_map[r][c] == ".":
                can_map[r][c] = "feasible"

            else:
                if c + 1 < C:
                    if want_map[r][c+1] == "#":
                        can_map[r][c] = "feasible"
                        can_map[r][c+1] = "feasible"
        else:
            if c + 1 < C:
                if want_map[r][c + 1] == "#":
                    can_map[r][c + 1] = "feasible"

        if r != 0:
            if (want_map[r][c] == "#") & (want_map[r-1][c] == "#"):
                can_map[r][c] = "feasible"
                can_map[r-1][c] = "feasible"

#    print("Can Map: {}".format(can_map))


# can_mapの中に"?"が残っていたらNo, なければYes
can_elements = []

for can_map_row in can_map:
    can_elements.extend(can_map_row)

if "?" in can_elements:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
lists = [input() for i in range(H)]
x = 1
y = 1
check = True
while(x<W-1 and y<H-1):
    if(lists[x][y] == "#"):
        if(x!=0 or y!=0 or x==W-1or y==H-1):
            if((lists[x+1][y] == ".") and (lists[x-1][y] == ".") and (lists[x][y-1] == ".") and (lists[x][y+1] == ".")):
                check = False
    x = x+1
    y = y+1
if(lists[0][0] == "#"):
     if(lists[0][1] == "." and lists[1][0] == "."):
        check = False
if(lists[H-1][0] == "#"):
     if(lists[H-2][0] == "." and lists[H-1][1] == "."):
            check = False
if(lists[0][W-1] == "#"):
    if(lists[0][W-2] == "." and lists[1][W-1] == "."):
        check = False
if(lists[H-1][W-1] == "#"):
    if(lists[H-2][W-1] == "." and lists[H-1][W-2] == "."):
        check = False
if(check):
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
lst = [[0 for x in range(W)] for y in range(H)]

for i in range(H):
  x = input().split()
  x = list(x[0])
  for j,l in enumerate(x):
    lst[i][j] = l

for i in range(H):
  for j in range(W):
    checker = []
    if lst[i][j] == '#':
      if i != 0:
        num = 1 if lst[i - 1][j] == '.' else 0
        checker.append(num)
      if i != H - 1:
        num = 1 if lst[i + 1][j] == '.' else 0
        checker.append(num)
      if j != 0:
        num = 1 if lst[i][j - 1] == '.' else 0
        checker.append(num)
      if j != W - 1:
        num = 1 if lst[i][j + 1] == '.' else 0
        checker.append(num)
    
    if len(checker) == sum(checker) and len(checker) != 0:
      print(False)
      exit()

print(True)

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
l = []
for _ in range(h):
    l.append(input())

x = [1,0,-1,0]
y = [0,1,0,-1]

flag = False

#normal
for i in range(1,h-1):
    for j in range(1,w-1):
        if(l[i][j] == '#'):
            for k in range(4):
                if(l[i + x[k]][j + y[k]] == '#'):
                    flag = True
                    break
            else:
                continue
            break

#tate



if(flag == True):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from itertools import repeat, product

def get_targets(a_grid):
    h = len(a_grid)
    w = len(a_grid[0])

    targets = [t for t in product(range(h), range(w)) if a_grid[t[0]][t[1]] == '#']

    return targets

def get_arounds(t, h, w):
    arounds = map(lambda a: (t[0] + a[0], t[1] + a[1]), ((0, 1), (1, 0), (0, -1), (-1, 0)))

    return list(filter(lambda x: -1 < x[0] < w and -1 < x[1] < h, arounds))

def main():
    h, w = tuple(map(int, input().split()))
    a_grid = [list(input()) for _ in range(h)]

    grid = [list(repeat('#', w)) for _ in range(h)]

    targets = get_targets(a_grid)

    if all([any([(t in targets) for t in get_arounds(target, h, w)]) for target in targets]):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
lists = [input() for i in range(H)]
x = 1
y = 1
check = True
while(x<W-1 and y<H-1):
    if(lists[x][y] == "#"):
        if(x!=0 or y!=0 or x==W-1or y==H-1):
            if((lists[x+1][y] == ".") and (lists[x-1][y] == ".") and (lists[x][y-1] == ".") and (lists[x][y+1] == ".")):
                check = False
    x = x+1
    y = y+1
if(lists[0][0] == "#"):
     if(lists[0][1] == "." and lists[1][0] == "."):
        check = False
if(lists[H-1][0] == "#"):
     if(lists[H-2][0] == "." and lists[H-1][1] == "."):
            check = False
if(lists[0][W-1] == "#"):
    if(lists[0][W-2] == "." and lists[1][W-1]):
        check = False
if(lists[H-1][W-1] == "#"):
    if(lists[H-2][W-1] == "." and lists[H-1][W-2] == "."):
        check = False
if(check):
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())

T=0
if H==1 & W==1:
	print("No")
	T=1


D=0
Numlist = []
for i in range(H):
	D+=10
	I=0
	RawList = []
	RawList = list(input())

	for j in range(W):
		CheckNum = RawList[j]
		I+=1

		if CheckNum == "#":
			Numlist.append(D+I)

N=0
for k in range(len(Numlist)):
	A = Numlist[k]
#	print(A)

	OK=0

	if (A+1) in Numlist:
		OK+=1
	if (A-1) in Numlist:
		OK+=1
	if (A+10) in Numlist:
		OK+=1
	if (A-10) in Numlist:
		OK+=1

	if OK == 0 and T==0:
		print("No")
		N=1
		break
#	print(OK)

if N==0 and T==0:
	print("Yes")

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(input()))
judge = True
for i in range(h):
    for j in range(w):
        if a[i][j]==".":
            continue
        if i>0 and a[i-1][j]=="#":
            break
        if j>0 and a[i][j-1]=="#":
            break
        if j<w-1 and a[i][j+1]=="#":
            break
        if i<h-1 and a[i+1][j]=="#":
            break
        judge =False
    if not judge :
        break
print("Yes" if judge else "No")

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = []
for _ in range(h):
    si = list(input())
    s.append(si[:-1])
flag = 1

for hi in range(h):
    for wi in range(w-1):
        black = 0
        if s[hi][wi] == '#':
            if hi > 0:
                if s[hi-1][wi] == '#':
                    black += 1
            if wi > 0:
                if s[hi][wi-1] == '#':
                    black += 1
            if hi < h-1:
                if s[hi+1][wi] == '#':
                    black += 1
            if wi < w-2:
                if s[hi][wi+1] == '#':
                    black += 1
            
            if black == 0:
                flag = 0
                break
    
    if flag == 0:
        break

if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
nums = list(map(int, input().split()))
H=nums[0]
W=nums[1]
Strings=[]
for k in range(H):
    Strings.append(input())
c=0
for i in range(H):
    list(Strings[i])
    for j in range(1, W):
        if Strings[i][j]=="#" and Strings[i][j-1]=="#":
            c=1
            break
for l in range(W):
    for m in range(1,H):
        if Strings[m][l]=="#" and Strings[m-1][l]=="#":
            c=1
            break
if c==1:
    print("Yes") 
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
H,W = map(int,input().split())
temp =[0 for i in range(H)]
for i in range(H):
    temp[i] = input()
dx = [-1,1,0,0]
dy = [0,0,1,-1]

for j in range(H):
    for k in range(W):
        now_point=[j,k]
        # print(now_point)
        if temp[now_point[0]][now_point[1]] == "#":
            # temp_count1 = 0
            temp_count2 = 0
            for i in range(4):
                serch_point = [now_point[0]+dx[i],now_point[1]+dy[i]]
                if 0 <= serch_point[0] < H and 0 <= serch_point[1] < W:
                        # temp_count += 1
                    if temp[serch_point[0]][serch_point[1]] == "#":   
                        temp_count2 += 1
            # if temp_count1 == temp_count2:
            if temp_count2 == 0:
                print("No")
                sys.exit()
            now_point =[serch_point[0],serch_point[1]]
count = 0
for i in range(H):
    if  "#" in temp[i]:
        count += 1
if count ==0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
H,W = list(map(int,raw_input().split()))
field = []
answer = "Yes"
for i in range (H):
    li = list(raw_input().strip())
    field.append(li[:])
def check(a,b):
    if field[a][b] ==".":
        return True
    check_li = [[a-1,b],[a+1,b],[a,b+1],[a,b-1]]
    check_li = filter(lambda x: 0 <= x[0] <= H-1 and 0<= x[1] <=W-1,check_li )
    for i in check_li:
        if field[i[0]][i[1]] == "#":
            return True
            break
    else:
        print a,b,field[i[0]][i[1]]
        return False
for i in range (H):
    for j in range (W):
        if check(i,j) == False:
            answer = "No"
            break
print answer

Submission status: Wrong Answer

Solution code:
def abc096_c():
    import numpy as np
    h, w = map(int, input().split())
    c = np.zeros([h + 2, w + 2], dtype=int)
    for i in range(h):
        row = "." + input() + "."
        for j in range(w + 2):
            c[i + 1][j] = [0, 1][row[j] == "#"]

    for i in range(1, h + 2):
        for j in range(1, w + 2):
            if c[i][j] == 1 and np.sum(c[i][j] * [c[i - 1][j], c[i + 1][j], c[i][j - 1], c[i][j + 1]]) == 0:
                return "No"
            else:
                return "Yes"


print(abc096_c())

Submission status: Wrong Answer

Solution code:
d = list(map(int,input().split()))
at = []
at.append(["."]*(d[1]+2))
for i in range(d[0]):
  at.append(list(input()))
  at[i+1].insert(0,".")
  at[i+1].insert(d[1],".")
at.append(["."]*(d[1]+2))
l = [[1,0],[0,1],[-1,0],[0,-1]]
re = True
op = False
def ao(k, re,op,l):
  ppp = True
  for a in range(1,d[0]):
    for b in range(1,d[1]):
      for dx,dy in l:
        if k[a][b] =="#" and k[a+dx][b+dy] ==".":
          re = False
        elif k[a][b] =="#" and k[a+dx][b+dy] =="#":
          op = True
      if op == True:
        re = True
      elif re == False:
        ppp = False
      op = False
  if ppp == False:
    return False
  else:
    return re
if ao(at,re,op,l) == True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def abc096_c():
    import numpy as np
    h, w = map(int, input().split())
    c = np.zeros([h + 2, w + 2], dtype=int)
    for i in range(h):
        row = "." + input() + "."
        for j in range(w + 2):
            c[i + 1][j] = [0, 1][row[j] == "#"]

    for i in range(1, h + 2):
        for j in range(i, w + 2):
            if c[i][j] == 1 and np.sum(c[i][j] * [c[i - 1][j], c[i + 1][j], c[i][j - 1], c[i][j + 1]]) == 0:
                return "No"
            else:
                return "Yes"


print(abc096_c())

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
H,W = list(map(int,raw_input().split()))
field = []
answer = "Yes"
for i in range (H):
    li = list(raw_input().strip())
    field.append(li[:])

    
def check(a,b):
    if field[a][b] ==".":
        return True
    check_li = [[a-1,b],[a+1,b],[a,b+1],[a,b-1]]
    check_li = filter(lambda x: 0 <= x[0] <= H-1 and 0<= x[1] <=W-1,check_li )
    for i in check_li:
        if field[i[0]][i[1]] == "#":
            return True
            break
    else:
        print a,b,field[i[0]][i[1]]
        return False

for i in range (H):
    for j in range (W):
        if check(i,j) == False:
            answer = "No"
            break
print answer

Submission status: Wrong Answer

Solution code:
def abc096_c():
    import numpy as np
    h, w = map(int, input().split())
    c = np.zeros([h + 2, w + 2], dtype=int)
    for i in range(h):
        row = "." + input() + "."
        for j in range(w + 2):
            c[i + 1][j] = [0, 1][row[j] == "#"]

    for i in range(1, h + 1):
        for j in range(i, w + 2):
            if c[i][j] == 1 and np.sum(c[i][j] * [c[i - 1][j], c[i + 1][j], c[i][j - 1], c[i][j + 1]]) == 0:
                return "No"
            else:
                return "Yes"


print(abc096_c())

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
lists = [input() for i in range(H)]
x = 1
y = 1
check = True
while(x<W-1 and y<H-1):
    if(lists[x][y] == "#"):
        if(x!=0 or y!=0 or x==W-1or y==H-1):
            if((lists[x+1][y] == ".") and (lists[x-1][y] == ".") and (lists[x][y-1] == ".") and (lists[x][y+1] == ".")):
                check = False
    x = x+1
    y = y+1
if(check):
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())  # 入力

s = [0 for i in range(h)]
for i in range(h):
    s[i] = list(input())

print(s[0][0])
flag = False
for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '#':
            if s[i-1][j] == "#" or s[i+1][j] == "#" or s[i][j-1] == "#" or s[i][j+1] == "#":
                flag = True
            else:
                flag = False
        

if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())


D=0
Numlist = []
for i in range(H):
	D+=10
	I=0
	RawList = []
	RawList = list(input())

	for j in range(W):
		CheckNum = RawList[j]
		I+=1

		if CheckNum == "#":
			Numlist.append(D+I)

N=0
for k in range(len(Numlist)):
	A = Numlist[k]

	OK=0

	if (A+1) in Numlist:
		OK+=1
	if (A-1) in Numlist:
		OK+=1
	if (A+10) in Numlist:
		OK+=1
	if (A-10) in Numlist:
		OK+=1

	if OK == 0:
		print("No")
		N=1
		break

if N==0:
	print("Yes")

Submission status: Wrong Answer

Solution code:
w, h = (int(i) for i in input().split())  
s = [[i for i in list(input())] for i in range(w)] 


for i in range(w):
    for j in range(h):
        if s[i][j] == '#':
            if j-1<0 and i+1>=w and j+1>=h and i-1>=0:
                if s[i-1][j] == '#' or s[i+1][j] == '#'  or s[i][j+1] == '#':
                    continue
                else:
                    print("No")
                    exit()        
            elif i-1<0 and j-1>=0 and j+1<=h and i+1>=w:
                if  s[i+1][j] == '#' or s[i][j-1] == '#' or s[i][j+1] == '#':
                    continue
                else:
                    print("No")
                    exit() 
            elif j-1>=0 and i+1<=w and j+1>=h and i-1 >=0:
                if s[i-1][j] == '#' or s[i+1][j] == '#' or s[i][j-1] == '#' :
                    continue
                else:
                    print("No")
                    exit() 
            elif j-1<0 and i+1>=w and j+1<=h and i-1 >=0 :
                if s[i-1][j] == '#'  or s[i][j-1] == '#' or s[i][j+1] == '#':
                    continue
                else:
                    print("No")
                    exit()  
            elif j-1<0 and i+1<=w and j+1<=h and i-1 >=0 :
                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")