結果
問題 |
No.2412 YOU Grow Bigger!
|
ユーザー |
![]() |
提出日時 | 2023-08-11 22:58:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 792 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 82,076 KB |
実行使用メモリ | 105,688 KB |
最終ジャッジ日時 | 2024-11-18 18:12:43 |
合計ジャッジ時間 | 13,432 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 WA * 2 |
ソースコード
h,w = map(int,input().split()) s = [input()+"#" for _ in range(h)]+["#"*(w+1)] def check(t): f = [[False]*(w+1) for _ in range(h+1)] f[1][1] = True; st = [(1,1)] while st: px,py = st.pop() for dx,dy in ((-1,0),(0,-1),(0,1),(1,0)): nx,ny = px+dx,py+dy if f[nx][ny]: continue g = True 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)