結果

問題 No.2646 Cycle Maze
ユーザー mkawa2mkawa2
提出日時 2024-02-25 23:46:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,548 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 266,556 KB
最終ジャッジ日時 2024-02-25 23:46:32
合計ジャッジ時間 22,159 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
62,408 KB
testcase_01 AC 41 ms
55,604 KB
testcase_02 AC 41 ms
55,604 KB
testcase_03 AC 40 ms
55,604 KB
testcase_04 AC 40 ms
55,604 KB
testcase_05 AC 43 ms
55,604 KB
testcase_06 AC 39 ms
55,604 KB
testcase_07 AC 40 ms
55,604 KB
testcase_08 AC 40 ms
55,604 KB
testcase_09 AC 40 ms
55,604 KB
testcase_10 AC 40 ms
55,604 KB
testcase_11 AC 40 ms
55,604 KB
testcase_12 AC 40 ms
55,604 KB
testcase_13 AC 39 ms
55,604 KB
testcase_14 AC 46 ms
55,604 KB
testcase_15 AC 41 ms
55,604 KB
testcase_16 AC 41 ms
55,604 KB
testcase_17 AC 40 ms
55,604 KB
testcase_18 AC 40 ms
55,604 KB
testcase_19 AC 42 ms
55,604 KB
testcase_20 AC 42 ms
55,604 KB
testcase_21 AC 44 ms
55,604 KB
testcase_22 AC 44 ms
55,604 KB
testcase_23 AC 43 ms
55,604 KB
testcase_24 AC 42 ms
55,604 KB
testcase_25 AC 556 ms
93,260 KB
testcase_26 AC 1,010 ms
120,752 KB
testcase_27 AC 2,471 ms
256,856 KB
testcase_28 AC 591 ms
96,164 KB
testcase_29 AC 451 ms
90,420 KB
testcase_30 AC 714 ms
101,520 KB
testcase_31 AC 46 ms
63,768 KB
testcase_32 AC 66 ms
72,648 KB
testcase_33 AC 726 ms
103,724 KB
testcase_34 AC 1,848 ms
199,368 KB
testcase_35 AC 1,684 ms
188,288 KB
testcase_36 AC 1,097 ms
128,096 KB
testcase_37 AC 584 ms
95,564 KB
testcase_38 AC 116 ms
77,536 KB
testcase_39 AC 1,005 ms
121,840 KB
testcase_40 AC 47 ms
61,700 KB
testcase_41 AC 1,185 ms
135,388 KB
testcase_42 AC 732 ms
106,652 KB
testcase_43 AC 209 ms
80,960 KB
testcase_44 AC 752 ms
104,548 KB
testcase_45 TLE -
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,defaultdict

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 = defaultdict(lambda :-1)
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+1 == T: continue
    nk = (k+1)%L
    nij=ij
    push()
    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