結果

問題 No.2412 YOU Grow Bigger!
ユーザー ニックネームニックネーム
提出日時 2023-08-11 23:09:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,339 ms / 6,000 ms
コード長 805 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,976 KB
実行使用メモリ 119,664 KB
最終ジャッジ日時 2024-05-01 06:38:05
合計ジャッジ時間 19,558 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,956 KB
testcase_01 AC 34 ms
52,908 KB
testcase_02 AC 51 ms
68,968 KB
testcase_03 AC 2,304 ms
118,876 KB
testcase_04 AC 2,132 ms
117,748 KB
testcase_05 AC 2,156 ms
110,588 KB
testcase_06 AC 2,339 ms
115,312 KB
testcase_07 AC 2,195 ms
119,664 KB
testcase_08 AC 2,319 ms
113,504 KB
testcase_09 AC 50 ms
66,744 KB
testcase_10 AC 167 ms
77,304 KB
testcase_11 AC 50 ms
66,584 KB
testcase_12 AC 39 ms
58,792 KB
testcase_13 AC 199 ms
77,848 KB
testcase_14 AC 87 ms
76,720 KB
testcase_15 AC 37 ms
59,692 KB
testcase_16 AC 49 ms
67,256 KB
testcase_17 AC 51 ms
69,508 KB
testcase_18 AC 480 ms
80,528 KB
testcase_19 AC 34 ms
53,136 KB
testcase_20 AC 51 ms
68,116 KB
testcase_21 AC 169 ms
77,148 KB
testcase_22 AC 206 ms
77,568 KB
testcase_23 AC 742 ms
82,360 KB
testcase_24 AC 1,168 ms
90,516 KB
testcase_25 AC 661 ms
81,720 KB
testcase_26 AC 139 ms
76,724 KB
testcase_27 AC 108 ms
76,988 KB
testcase_28 AC 274 ms
78,344 KB
testcase_29 AC 33 ms
52,944 KB
testcase_30 AC 41 ms
63,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = map(int,input().split())
s = [input()+"#" for _ in range(h)]+["#"*(w+1)]
def check(t):
    f = [[False]*w for _ in range(h)]; f[1][1] = True; st = [(1,1)]
    while st:
        px,py = st.pop()
        for dx in range(-1,2):
            for dy in range(-1,2):
                nx,ny = px+dx,py+dy; g = True
                if f[nx][ny]: continue
                for i in range(-1,2):
                    for j in range(-1,2):
                        g &= t[nx+i][ny+j]=="."
                if g: f[nx][ny] = True; st.append((nx,ny))
    return f[h-2][w-2]
if not check(s): exit(print(0))
for i in range(h):
    for j in range(w):
        if 0<=i<=2 and 0<=j<=2 or h-3<=i<=h-1 and w-3<=j<=w-1: continue
        t = [list(si) for si in s]; t[i][j] = "#"
        if not check(t): exit(print(1))
print(2)
0