結果

問題 No.2412 YOU Grow Bigger!
ユーザー titiatitia
提出日時 2023-11-23 01:20:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,517 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 80,852 KB
最終ジャッジ日時 2023-11-23 01:21:08
合計ジャッジ時間 11,183 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 45 ms
61,972 KB
testcase_03 AC 1,140 ms
80,696 KB
testcase_04 AC 1,214 ms
80,820 KB
testcase_05 AC 804 ms
78,860 KB
testcase_06 AC 1,144 ms
80,080 KB
testcase_07 AC 1,159 ms
80,852 KB
testcase_08 AC 1,335 ms
80,092 KB
testcase_09 AC 52 ms
66,540 KB
testcase_10 AC 128 ms
76,484 KB
testcase_11 AC 45 ms
62,208 KB
testcase_12 AC 36 ms
53,460 KB
testcase_13 AC 155 ms
76,668 KB
testcase_14 AC 53 ms
66,524 KB
testcase_15 AC 37 ms
53,460 KB
testcase_16 AC 48 ms
62,356 KB
testcase_17 AC 55 ms
66,512 KB
testcase_18 AC 273 ms
76,648 KB
testcase_19 AC 37 ms
53,460 KB
testcase_20 AC 50 ms
64,432 KB
testcase_21 WA -
testcase_22 AC 145 ms
76,536 KB
testcase_23 AC 245 ms
76,896 KB
testcase_24 AC 713 ms
77,292 KB
testcase_25 WA -
testcase_26 AC 129 ms
76,652 KB
testcase_27 AC 87 ms
76,108 KB
testcase_28 AC 205 ms
76,664 KB
testcase_29 AC 36 ms
53,460 KB
testcase_30 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
                
0