結果

問題 No.2646 Cycle Maze
ユーザー mkawa2mkawa2
提出日時 2024-02-25 18:51:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,506 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 847,620 KB
最終ジャッジ日時 2024-02-25 18:51:55
合計ジャッジ時間 14,648 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,600 KB
testcase_01 AC 40 ms
55,600 KB
testcase_02 AC 39 ms
55,600 KB
testcase_03 AC 39 ms
55,600 KB
testcase_04 AC 38 ms
55,600 KB
testcase_05 AC 38 ms
55,600 KB
testcase_06 AC 38 ms
55,600 KB
testcase_07 AC 41 ms
55,600 KB
testcase_08 WA -
testcase_09 AC 39 ms
55,600 KB
testcase_10 AC 39 ms
55,600 KB
testcase_11 WA -
testcase_12 AC 38 ms
55,600 KB
testcase_13 WA -
testcase_14 AC 38 ms
55,600 KB
testcase_15 WA -
testcase_16 AC 38 ms
55,600 KB
testcase_17 AC 38 ms
55,600 KB
testcase_18 WA -
testcase_19 AC 42 ms
55,600 KB
testcase_20 AC 40 ms
55,600 KB
testcase_21 WA -
testcase_22 AC 39 ms
55,600 KB
testcase_23 AC 40 ms
55,600 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 462 ms
287,760 KB
testcase_27 AC 959 ms
486,264 KB
testcase_28 AC 297 ms
148,624 KB
testcase_29 AC 389 ms
294,160 KB
testcase_30 WA -
testcase_31 AC 287 ms
317,328 KB
testcase_32 AC 70 ms
90,168 KB
testcase_33 AC 527 ms
366,480 KB
testcase_34 AC 678 ms
503,176 KB
testcase_35 AC 628 ms
309,776 KB
testcase_36 AC 550 ms
345,232 KB
testcase_37 MLE -
testcase_38 AC 108 ms
112,396 KB
testcase_39 AC 431 ms
241,040 KB
testcase_40 AC 158 ms
179,984 KB
testcase_41 AC 533 ms
296,848 KB
testcase_42 AC 306 ms
130,984 KB
testcase_43 AC 130 ms
102,924 KB
testcase_44 AC 330 ms
132,364 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-1)%aa[nij]==0:return
    dist[nij][nk] = d+1
    q.append((nij, nk))

while q:
    ij, k = q.popleft()
    if ij == gij:
        print("Yes")
        exit()
    i, j = divmod(ij, w)
    d = dist[ij][k]
    if d+1 == 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