結果
| 問題 | No.2412 YOU Grow Bigger! | 
| コンテスト | |
| ユーザー |  titia | 
| 提出日時 | 2023-11-23 01:20:56 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,517 bytes | 
| コンパイル時間 | 370 ms | 
| コンパイル使用メモリ | 82,364 KB | 
| 実行使用メモリ | 81,216 KB | 
| 最終ジャッジ日時 | 2024-09-26 07:44:30 | 
| 合計ジャッジ時間 | 11,307 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 27 WA * 2 | 
ソースコード
import sys
input = sys.stdin.readline
H,W=map(int,input().split())
S=[list(input().strip()) for i in range(H)]
OK=[[0]*W for i in range(H)]
OK[2][2]=1
Q=[(2,2)]
while Q:
    x,y=Q.pop()
    for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
        if 2<=z<H and 2<=w<W and OK[z][w]==0:
            flag=1
            for x0 in range(3):
                for y0 in range(3):
                    if S[z-x0][w-y0]=="#":
                        flag=0
                        break
            if flag==1:
                OK[z][w]=1
                Q.append((z,w))
if OK[H-1][W-1]==0:
    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 S[i][j]=="#":
            continue
    
        S[i][j]="#"
        OK=[[0]*W for i in range(H)]
        OK[2][2]=1
        Q=[(2,2)]
        while Q:
            x,y=Q.pop()
            for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
                if 2<=z<H and 2<=w<W and OK[z][w]==0:
                    flag=1
                    for x0 in range(3):
                        for y0 in range(3):
                            if S[z-x0][w-y0]=="#":
                                flag=0
                                break
                    if flag==1:
                        OK[z][w]=1
                        Q.append((z,w))
        if OK[H-1][W-1]==0:
            print(1)
            exit()
        S[i][j]="."
print(2)
                
            
            
            
        