結果

問題 No.2646 Cycle Maze
ユーザー titiatitia
提出日時 2024-02-26 01:02:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,806 ms / 2,500 ms
コード長 886 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 183,644 KB
最終ジャッジ日時 2024-02-26 01:02:51
合計ジャッジ時間 15,289 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 56 ms
68,576 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 34 ms
53,460 KB
testcase_06 AC 34 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 35 ms
53,460 KB
testcase_09 AC 36 ms
53,460 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 36 ms
53,460 KB
testcase_13 AC 36 ms
53,460 KB
testcase_14 AC 37 ms
53,460 KB
testcase_15 AC 35 ms
53,460 KB
testcase_16 AC 34 ms
53,460 KB
testcase_17 AC 34 ms
53,460 KB
testcase_18 AC 34 ms
53,460 KB
testcase_19 AC 36 ms
53,460 KB
testcase_20 AC 34 ms
53,460 KB
testcase_21 AC 35 ms
53,460 KB
testcase_22 AC 42 ms
62,100 KB
testcase_23 AC 35 ms
53,460 KB
testcase_24 AC 34 ms
53,460 KB
testcase_25 AC 103 ms
76,440 KB
testcase_26 AC 131 ms
77,220 KB
testcase_27 AC 258 ms
81,672 KB
testcase_28 AC 95 ms
76,116 KB
testcase_29 AC 99 ms
76,580 KB
testcase_30 AC 104 ms
76,324 KB
testcase_31 AC 62 ms
72,984 KB
testcase_32 AC 65 ms
73,420 KB
testcase_33 AC 135 ms
77,836 KB
testcase_34 AC 224 ms
81,288 KB
testcase_35 AC 167 ms
77,720 KB
testcase_36 AC 138 ms
77,192 KB
testcase_37 AC 153 ms
78,216 KB
testcase_38 AC 73 ms
76,260 KB
testcase_39 AC 119 ms
76,452 KB
testcase_40 AC 59 ms
70,564 KB
testcase_41 AC 130 ms
77,220 KB
testcase_42 AC 99 ms
76,360 KB
testcase_43 AC 79 ms
76,384 KB
testcase_44 AC 97 ms
76,348 KB
testcase_45 AC 536 ms
104,668 KB
testcase_46 AC 566 ms
105,948 KB
testcase_47 AC 133 ms
80,348 KB
testcase_48 AC 433 ms
96,348 KB
testcase_49 AC 495 ms
103,772 KB
testcase_50 AC 1,009 ms
135,132 KB
testcase_51 AC 1,776 ms
182,620 KB
testcase_52 AC 1,801 ms
178,652 KB
testcase_53 AC 1,609 ms
183,644 KB
testcase_54 AC 1,806 ms
180,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

H,W,T=map(int,input().split())
sx,sy=map(int,input().split())
gx,gy=map(int,input().split())

sx-=1
sy-=1
gx-=1
gy-=1

MAP=[input().strip() for i in range(H)]
OK=[[0]*W for i in range(H)]
OK[sx][sy]=1

for turns in range(1,T):
    A=[[0]*W for i in range(H)]
    
    for i in range(H):
        for j in range(W):
            if MAP[i][j]!="0":
                A[i][j]=(int(MAP[i][j])-turns)%(1+int(MAP[i][j]))

    #print("!",A)
    OK2=[[0]*W for i in range(H)]

    for i in range(H):
        for j in range(W):
            if OK[i][j]==1:
                for z,w in [(i,j),(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
                    if 0<=z<H and 0<=w<W and A[z][w]>0:
                        OK2[z][w]=1

    OK=OK2

    if OK[gx][gy]==1:
        print("Yes")
        exit()

    #print(OK)

print("No")
                        

    
            
0