結果

問題 No.2646 Cycle Maze
ユーザー 👑 rin204rin204
提出日時 2024-03-16 15:00:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 888 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 254,184 KB
最終ジャッジ日時 2024-03-16 15:00:53
合計ジャッジ時間 18,385 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 46 ms
61,972 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 39 ms
53,460 KB
testcase_08 AC 38 ms
53,460 KB
testcase_09 AC 39 ms
53,460 KB
testcase_10 AC 49 ms
62,100 KB
testcase_11 AC 39 ms
53,460 KB
testcase_12 AC 39 ms
53,460 KB
testcase_13 AC 38 ms
53,460 KB
testcase_14 AC 38 ms
53,460 KB
testcase_15 AC 38 ms
53,460 KB
testcase_16 AC 38 ms
53,460 KB
testcase_17 AC 38 ms
53,460 KB
testcase_18 AC 37 ms
53,460 KB
testcase_19 AC 39 ms
53,460 KB
testcase_20 AC 39 ms
53,460 KB
testcase_21 AC 38 ms
53,460 KB
testcase_22 AC 42 ms
59,588 KB
testcase_23 AC 38 ms
53,456 KB
testcase_24 AC 37 ms
53,460 KB
testcase_25 AC 1,172 ms
123,964 KB
testcase_26 AC 854 ms
109,136 KB
testcase_27 AC 801 ms
118,376 KB
testcase_28 AC 211 ms
83,268 KB
testcase_29 AC 1,243 ms
126,116 KB
testcase_30 AC 901 ms
109,004 KB
testcase_31 AC 576 ms
103,608 KB
testcase_32 AC 60 ms
68,460 KB
testcase_33 AC 98 ms
82,064 KB
testcase_34 AC 209 ms
93,520 KB
testcase_35 AC 656 ms
105,496 KB
testcase_36 AC 155 ms
84,004 KB
testcase_37 AC 271 ms
99,520 KB
testcase_38 AC 200 ms
81,032 KB
testcase_39 AC 808 ms
108,420 KB
testcase_40 AC 403 ms
90,912 KB
testcase_41 AC 659 ms
104,376 KB
testcase_42 AC 167 ms
79,356 KB
testcase_43 AC 137 ms
78,540 KB
testcase_44 AC 323 ms
86,584 KB
testcase_45 AC 914 ms
136,692 KB
testcase_46 AC 1,089 ms
156,068 KB
testcase_47 TLE -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
権限があれば一括ダウンロードができます

ソースコード

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)]
T -= 1
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, 0]
dj = [1, 0, -1, 0, 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(5):
                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