結果

問題 No.2646 Cycle Maze
ユーザー mkawa2mkawa2
提出日時 2024-02-25 19:02:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,521 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 848,136 KB
最終ジャッジ日時 2024-02-25 19:02:13
合計ジャッジ時間 12,300 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,604 KB
testcase_01 AC 38 ms
55,604 KB
testcase_02 AC 38 ms
55,604 KB
testcase_03 AC 39 ms
55,604 KB
testcase_04 AC 39 ms
55,604 KB
testcase_05 AC 39 ms
55,604 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 39 ms
55,604 KB
testcase_09 AC 39 ms
55,604 KB
testcase_10 AC 40 ms
55,604 KB
testcase_11 AC 40 ms
55,604 KB
testcase_12 WA -
testcase_13 AC 38 ms
55,604 KB
testcase_14 AC 42 ms
55,604 KB
testcase_15 WA -
testcase_16 AC 38 ms
55,604 KB
testcase_17 WA -
testcase_18 AC 40 ms
55,604 KB
testcase_19 AC 40 ms
55,604 KB
testcase_20 AC 39 ms
55,604 KB
testcase_21 AC 40 ms
55,604 KB
testcase_22 AC 38 ms
55,604 KB
testcase_23 AC 38 ms
55,604 KB
testcase_24 AC 38 ms
55,604 KB
testcase_25 AC 385 ms
287,096 KB
testcase_26 AC 493 ms
287,580 KB
testcase_27 AC 907 ms
486,028 KB
testcase_28 AC 245 ms
147,476 KB
testcase_29 AC 360 ms
293,780 KB
testcase_30 AC 368 ms
243,500 KB
testcase_31 AC 296 ms
317,332 KB
testcase_32 AC 66 ms
90,172 KB
testcase_33 AC 523 ms
366,408 KB
testcase_34 AC 831 ms
504,428 KB
testcase_35 WA -
testcase_36 AC 550 ms
345,368 KB
testcase_37 MLE -
testcase_38 AC 139 ms
112,400 KB
testcase_39 AC 436 ms
241,088 KB
testcase_40 AC 154 ms
179,988 KB
testcase_41 AC 532 ms
296,808 KB
testcase_42 AC 300 ms
130,476 KB
testcase_43 AC 125 ms
102,800 KB
testcase_44 AC 309 ms
131,588 KB
testcase_45 MLE -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

from collections import deque

L = 2520

h, w, T = LI()
si, sj = LI1()
gi, gj = LI1()
aa = [int(c)+1 for _ in range(h) for c in SI()]

sij = si*w+sj
gij = gi*w+gj

dist = [[-1]*L for _ in range(h*w)]
dist[sij][0] = 0
q = deque()
q.append((sij, 0))

def push():
    if dist[nij][nk] != -1 or (-d-2)%aa[nij]==0:return
    dist[nij][nk] = d+1
    q.append((nij, nk))

while q:
    # print(q)
    ij, k = q.popleft()
    if ij == gij:
        print("Yes")
        exit()
    i, j = divmod(ij, w)
    d = dist[ij][k]
    if d == T: continue
    nk = (k+1)%L
    if i:
        nij = ij-w
        push()
    if i+1 < h:
        nij = ij+w
        push()
    if j:
        nij = ij-1
        push()
    if j+1 < w:
        nij = ij+1
        push()

print("No")
0