結果

問題 No.2646 Cycle Maze
ユーザー mkawa2mkawa2
提出日時 2024-02-26 00:18:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,830 ms / 2,500 ms
コード長 1,275 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 155,820 KB
最終ジャッジ日時 2024-02-26 00:18:39
合計ジャッジ時間 16,153 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,588 KB
testcase_01 AC 38 ms
53,588 KB
testcase_02 AC 36 ms
53,588 KB
testcase_03 AC 36 ms
53,588 KB
testcase_04 AC 35 ms
53,588 KB
testcase_05 AC 36 ms
53,588 KB
testcase_06 AC 35 ms
53,588 KB
testcase_07 AC 34 ms
53,588 KB
testcase_08 AC 35 ms
53,588 KB
testcase_09 AC 36 ms
53,588 KB
testcase_10 AC 39 ms
53,588 KB
testcase_11 AC 36 ms
53,588 KB
testcase_12 AC 35 ms
53,588 KB
testcase_13 AC 35 ms
53,588 KB
testcase_14 AC 36 ms
53,588 KB
testcase_15 AC 36 ms
53,588 KB
testcase_16 AC 35 ms
53,588 KB
testcase_17 AC 34 ms
53,588 KB
testcase_18 AC 36 ms
53,588 KB
testcase_19 AC 36 ms
53,588 KB
testcase_20 AC 39 ms
53,588 KB
testcase_21 AC 35 ms
53,588 KB
testcase_22 AC 35 ms
53,588 KB
testcase_23 AC 36 ms
53,588 KB
testcase_24 AC 36 ms
53,588 KB
testcase_25 AC 171 ms
76,952 KB
testcase_26 AC 209 ms
77,200 KB
testcase_27 AC 325 ms
85,200 KB
testcase_28 AC 195 ms
77,336 KB
testcase_29 AC 158 ms
76,560 KB
testcase_30 AC 182 ms
77,216 KB
testcase_31 AC 41 ms
61,700 KB
testcase_32 AC 51 ms
66,376 KB
testcase_33 AC 197 ms
77,068 KB
testcase_34 AC 268 ms
80,084 KB
testcase_35 AC 276 ms
77,972 KB
testcase_36 AC 217 ms
77,468 KB
testcase_37 AC 175 ms
77,344 KB
testcase_38 AC 68 ms
73,488 KB
testcase_39 AC 206 ms
77,472 KB
testcase_40 AC 40 ms
59,580 KB
testcase_41 AC 213 ms
77,320 KB
testcase_42 AC 240 ms
77,360 KB
testcase_43 AC 111 ms
76,060 KB
testcase_44 AC 218 ms
77,072 KB
testcase_45 AC 503 ms
107,708 KB
testcase_46 AC 546 ms
102,596 KB
testcase_47 AC 109 ms
77,752 KB
testcase_48 AC 375 ms
91,084 KB
testcase_49 AC 470 ms
97,724 KB
testcase_50 AC 927 ms
125,120 KB
testcase_51 AC 1,778 ms
150,424 KB
testcase_52 AC 1,778 ms
155,820 KB
testcase_53 AC 1,830 ms
155,620 KB
testcase_54 AC 1,765 ms
149,144 KB
権限があれば一括ダウンロードができます

ソースコード

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

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

def push(nij):
    if (-k-1)%aa[nij]==0:return
    now.add(nij)

now=set()
now.add(sij)
for k in range(1,T+1):
    pre,now=now,set()
    for ij in pre:
        if ij == gij:
            print("Yes")
            exit()
        i, j = divmod(ij, w)
        push(ij)
        if i:push(ij-w)
        if i+1 < h:push(ij+w)
        if j:push(ij-1)
        if j+1 < w:push(ij+1)

print("No")
0