結果

問題 No.2646 Cycle Maze
ユーザー mkawa2mkawa2
提出日時 2024-02-25 23:42:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,526 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 333,184 KB
最終ジャッジ日時 2024-02-25 23:43:10
合計ジャッジ時間 23,080 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,604 KB
testcase_01 AC 40 ms
55,604 KB
testcase_02 AC 40 ms
55,604 KB
testcase_03 AC 40 ms
55,604 KB
testcase_04 AC 39 ms
55,604 KB
testcase_05 AC 39 ms
55,604 KB
testcase_06 AC 40 ms
55,604 KB
testcase_07 WA -
testcase_08 AC 39 ms
55,604 KB
testcase_09 AC 38 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 40 ms
55,604 KB
testcase_14 AC 39 ms
55,604 KB
testcase_15 WA -
testcase_16 AC 40 ms
55,604 KB
testcase_17 WA -
testcase_18 AC 39 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 40 ms
55,604 KB
testcase_24 AC 40 ms
55,604 KB
testcase_25 AC 271 ms
84,488 KB
testcase_26 AC 471 ms
94,852 KB
testcase_27 AC 1,084 ms
154,548 KB
testcase_28 AC 320 ms
85,104 KB
testcase_29 AC 223 ms
82,628 KB
testcase_30 AC 319 ms
86,528 KB
testcase_31 AC 44 ms
61,700 KB
testcase_32 AC 48 ms
64,040 KB
testcase_33 AC 354 ms
87,588 KB
testcase_34 AC 808 ms
118,752 KB
testcase_35 WA -
testcase_36 AC 527 ms
95,392 KB
testcase_37 AC 323 ms
87,240 KB
testcase_38 AC 78 ms
76,904 KB
testcase_39 AC 439 ms
93,832 KB
testcase_40 AC 44 ms
61,700 KB
testcase_41 AC 616 ms
102,812 KB
testcase_42 AC 376 ms
89,836 KB
testcase_43 AC 117 ms
78,388 KB
testcase_44 AC 391 ms
89,696 KB
testcase_45 AC 1,984 ms
296,372 KB
testcase_46 AC 1,878 ms
283,768 KB
testcase_47 AC 138 ms
79,304 KB
testcase_48 AC 1,322 ms
202,780 KB
testcase_49 AC 1,584 ms
240,896 KB
testcase_50 TLE -
testcase_51 TLE -
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
    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