結果
問題 | No.2412 YOU Grow Bigger! |
ユーザー |
![]() |
提出日時 | 2023-08-11 23:09:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,738 ms / 6,000 ms |
コード長 | 805 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 82,384 KB |
実行使用メモリ | 119,544 KB |
最終ジャッジ日時 | 2024-11-21 08:45:44 |
合計ジャッジ時間 | 22,444 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
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)