結果

問題 No.2646 Cycle Maze
ユーザー nikoro256nikoro256
提出日時 2024-02-25 19:00:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,982 ms / 2,500 ms
コード長 1,057 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 157,644 KB
最終ジャッジ日時 2024-02-25 19:00:51
合計ジャッジ時間 15,759 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,608 KB
testcase_01 AC 40 ms
55,608 KB
testcase_02 AC 41 ms
55,608 KB
testcase_03 AC 52 ms
64,444 KB
testcase_04 AC 43 ms
55,604 KB
testcase_05 AC 44 ms
55,608 KB
testcase_06 AC 44 ms
55,608 KB
testcase_07 AC 44 ms
55,608 KB
testcase_08 AC 40 ms
55,608 KB
testcase_09 AC 41 ms
55,604 KB
testcase_10 AC 41 ms
55,608 KB
testcase_11 AC 41 ms
55,608 KB
testcase_12 AC 41 ms
55,608 KB
testcase_13 AC 43 ms
55,608 KB
testcase_14 AC 41 ms
55,608 KB
testcase_15 AC 40 ms
55,608 KB
testcase_16 AC 40 ms
55,608 KB
testcase_17 AC 40 ms
55,608 KB
testcase_18 AC 40 ms
55,608 KB
testcase_19 AC 42 ms
55,608 KB
testcase_20 AC 41 ms
55,608 KB
testcase_21 AC 41 ms
55,608 KB
testcase_22 AC 44 ms
61,588 KB
testcase_23 AC 44 ms
55,608 KB
testcase_24 AC 40 ms
55,608 KB
testcase_25 AC 89 ms
76,496 KB
testcase_26 AC 115 ms
76,744 KB
testcase_27 AC 234 ms
80,684 KB
testcase_28 AC 90 ms
76,244 KB
testcase_29 AC 86 ms
76,488 KB
testcase_30 AC 93 ms
76,376 KB
testcase_31 AC 52 ms
66,384 KB
testcase_32 AC 59 ms
68,476 KB
testcase_33 AC 100 ms
76,588 KB
testcase_34 AC 184 ms
79,156 KB
testcase_35 AC 158 ms
77,516 KB
testcase_36 AC 120 ms
76,996 KB
testcase_37 AC 101 ms
77,232 KB
testcase_38 AC 65 ms
72,640 KB
testcase_39 AC 109 ms
76,500 KB
testcase_40 AC 52 ms
64,308 KB
testcase_41 AC 118 ms
76,876 KB
testcase_42 AC 95 ms
76,356 KB
testcase_43 AC 74 ms
76,108 KB
testcase_44 AC 106 ms
76,240 KB
testcase_45 AC 474 ms
95,748 KB
testcase_46 AC 467 ms
96,488 KB
testcase_47 AC 86 ms
77,320 KB
testcase_48 AC 361 ms
88,196 KB
testcase_49 AC 401 ms
93,160 KB
testcase_50 AC 955 ms
119,372 KB
testcase_51 AC 1,830 ms
155,228 KB
testcase_52 AC 1,982 ms
156,896 KB
testcase_53 AC 1,839 ms
156,876 KB
testcase_54 AC 1,881 ms
157,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def bfs(s):
    dq=deque()
    dq.append([s,0])
    high=[10**9 for _ in range(N)]
    high[s]=0
    while len(dq)!=0:
        p,h=dq.popleft()
        for e in edge[p]:
            if  high[e]==10**9:
                dq.append([e,h+1])
                high[e]=h+1
    return high

H,W,T=map(int,input().split())
Sy,Sx=map(int,input().split())
Gy,Gx=map(int,input().split())
A=[]
for _ in range(H):
    tmp=input()
    A.append([int(tmp[i]) for i in range(W)])
dp=[[False]*W for _ in range(H)]
dp[Sy-1][Sx-1]=True
for i in range(T-1):
    ndp=[[False]*W for _ in range(H)]
    for j in range(H):
        for k in range(W):
            if dp[j][k]:
                for d1,d2 in [[1,0],[0,1],[-1,0],[0,-1],[0,0]]:
                    x=j+d1
                    y=k+d2
                    if 0<=x<H and 0<=y<W and (A[x][y]-i-1)%(A[x][y]+1)!=0:
                        ndp[x][y]=True
                        if x==Gy-1 and y==Gx-1:
                            print('Yes')
                            exit(0)
    dp=ndp
print('No')
0