結果

問題 No.2412 YOU Grow Bigger!
ユーザー mymelochanmymelochan
提出日時 2023-08-11 22:29:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 294 ms / 6,000 ms
コード長 1,706 bytes
コンパイル時間 569 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 78,536 KB
最終ジャッジ日時 2023-08-13 13:21:31
合計ジャッジ時間 6,410 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
71,536 KB
testcase_01 AC 98 ms
71,484 KB
testcase_02 AC 114 ms
77,068 KB
testcase_03 AC 238 ms
78,352 KB
testcase_04 AC 249 ms
78,336 KB
testcase_05 AC 252 ms
78,128 KB
testcase_06 AC 238 ms
78,304 KB
testcase_07 AC 241 ms
78,292 KB
testcase_08 AC 250 ms
78,060 KB
testcase_09 AC 112 ms
77,064 KB
testcase_10 AC 126 ms
77,288 KB
testcase_11 AC 106 ms
77,292 KB
testcase_12 AC 96 ms
71,540 KB
testcase_13 AC 130 ms
77,536 KB
testcase_14 AC 114 ms
77,076 KB
testcase_15 AC 98 ms
72,536 KB
testcase_16 AC 109 ms
77,380 KB
testcase_17 AC 118 ms
77,244 KB
testcase_18 AC 182 ms
77,528 KB
testcase_19 AC 94 ms
71,536 KB
testcase_20 AC 108 ms
77,228 KB
testcase_21 AC 133 ms
77,544 KB
testcase_22 AC 131 ms
77,780 KB
testcase_23 AC 291 ms
78,536 KB
testcase_24 AC 294 ms
78,236 KB
testcase_25 AC 173 ms
78,480 KB
testcase_26 AC 121 ms
77,364 KB
testcase_27 AC 122 ms
77,488 KB
testcase_28 AC 144 ms
77,524 KB
testcase_29 AC 102 ms
72,180 KB
testcase_30 AC 103 ms
75,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations
from math import sin,cos
#from math import isqrt #DO NOT USE PyPy

ipt = sys.stdin.readline
iin = lambda :int(ipt())
lmin = lambda :list(map(int,ipt().split()))

#############################################################

H,W = lmin()
T = [list(input()) for _ in range(H)]

st = [(1,1)]


d = []
for i in range(-1,2):
    for j in range(-1,2):
        if i|j == 0:
            continue
        d.append((i,j))

def func(S):
    st = [(1,1)]
    visited = [[0]*W for _ in range(H)]

    while st:
        i,j = st.pop()
        if i == H-2 and j == W-2:
            return True
        for di,dj in d:
            ni = di+i
            nj = dj+j
            if 1<=ni<H-1 and 1<=nj<W-1:
                if visited[ni][nj]:
                    continue
                visited[ni][nj] = 1
                g = 0
                for ii in range(-1,2):
                    for jj in range(-1,2):
                        if S[ni+ii][nj+jj] == "#":
                            g = 1
                if g == 0:
                    st.append((ni,nj))

    return False

if not func(T):
    print(0)
    exit()

for i in range(H):
    for j in range(W):
        if i <= 2 and j <= 2:
            continue
        if i >= H-3 and j >= W-3:
            continue
        if T[i][j] == ".":
            T[i][j] = "#"
            if not func(T):
                print(1)
                exit()
            T[i][j] = "."

print(2)
0