ABC088 D - Grid Repainting
提出
code: python
from collections import deque
h, w = map(int, input().split())
que = deque(0, 0)
while (len(que)):
now = que.popleft()
go = [now0 + i, now1 + j] break
if go0 < 0 or go0 >= h or go1 < 0 or go1 >= w: continue
continue
if visited[go0][go1] == False: ans = 0
for i in range(h):
for j in range(w):
if (sij == "." and visitedij == False): ans += 1
print(ans)
解答
code: python
from collections import deque
INF = 10**5
H, W = map(int,input().split())
cntSharp = 0
for i in range(H):
cntSharp += Si.count("#") dis = [INF*W for _ in range(H)] P = deque([])
P.append((0,0))
while P:
p = P.popleft()
for i in range(4):
if 0 <= nx and 0 <= ny and nx <= H-1 and ny <= W-1 and Snxny =="." and disnxny == INF: P.append((nx,ny))
print(-1)
else:
print(H*W - disH-1W-1 - cntSharp - 1) テーマ