結果

問題 No.2646 Cycle Maze
ユーザー 👑 rin204rin204
提出日時 2024-03-16 14:56:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 263,948 KB
最終ジャッジ日時 2024-03-16 14:56:48
合計ジャッジ時間 21,138 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 46 ms
61,968 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 38 ms
53,460 KB
testcase_12 WA -
testcase_13 AC 37 ms
53,460 KB
testcase_14 AC 37 ms
53,460 KB
testcase_15 WA -
testcase_16 AC 37 ms
53,460 KB
testcase_17 WA -
testcase_18 AC 37 ms
53,460 KB
testcase_19 AC 38 ms
53,460 KB
testcase_20 AC 38 ms
53,460 KB
testcase_21 AC 38 ms
53,460 KB
testcase_22 AC 40 ms
59,584 KB
testcase_23 AC 37 ms
53,460 KB
testcase_24 AC 39 ms
53,460 KB
testcase_25 AC 636 ms
124,036 KB
testcase_26 AC 463 ms
109,224 KB
testcase_27 AC 476 ms
118,540 KB
testcase_28 AC 147 ms
83,292 KB
testcase_29 AC 665 ms
126,204 KB
testcase_30 AC 455 ms
109,084 KB
testcase_31 AC 341 ms
103,712 KB
testcase_32 AC 54 ms
66,520 KB
testcase_33 AC 86 ms
81,128 KB
testcase_34 AC 164 ms
93,692 KB
testcase_35 WA -
testcase_36 AC 92 ms
81,148 KB
testcase_37 AC 211 ms
99,704 KB
testcase_38 AC 137 ms
81,020 KB
testcase_39 AC 446 ms
108,480 KB
testcase_40 AC 249 ms
90,952 KB
testcase_41 AC 400 ms
104,172 KB
testcase_42 AC 112 ms
79,092 KB
testcase_43 AC 104 ms
78,408 KB
testcase_44 AC 201 ms
86,596 KB
testcase_45 AC 549 ms
137,000 KB
testcase_46 AC 736 ms
156,376 KB
testcase_47 AC 1,972 ms
247,952 KB
testcase_48 AC 576 ms
141,376 KB
testcase_49 AC 1,943 ms
252,012 KB
testcase_50 AC 685 ms
166,684 KB
testcase_51 AC 1,239 ms
211,376 KB
testcase_52 AC 1,332 ms
221,192 KB
testcase_53 AC 1,767 ms
263,948 KB
testcase_54 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w, T = map(int, input().split())
si, sj = map(int, input().split())
gi, gj = map(int, input().split())
si -= 1
sj -= 1
gi -= 1
gj -= 1
A = [list(map(int, input())) for _ in range(h)]

dp = [False] * (h * w * (T + 1))


def f(t, i, j):
    return (t * h + i) * w + j


dp[f(0, si, sj)] = True

di = [0, 1, 0, -1]
dj = [1, 0, -1, 0]
for t in range(T):
    for i in range(h):
        for j in range(w):
            if not dp[f(t, i, j)]:
                continue
            for k in range(4):
                ni = i + di[k]
                nj = j + dj[k]
                if ni < 0 or ni >= h or nj < 0 or nj >= w:
                    continue
                b = (A[ni][nj] - t - 1) % (A[ni][nj] + 1)
                if b != 0:
                    dp[f(t + 1, ni, nj)] = True

if any(dp[f(t, gi, gj)] for t in range(T + 1)):
    print("Yes")
    exit()
else:
    print("No")
0