結果

問題 No.2646 Cycle Maze
ユーザー 👑 rin204rin204
提出日時 2024-03-16 15:00:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 888 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 248,260 KB
最終ジャッジ日時 2024-09-30 04:01:35
合計ジャッジ時間 18,270 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,532 KB
testcase_01 AC 35 ms
51,968 KB
testcase_02 AC 37 ms
52,224 KB
testcase_03 AC 44 ms
60,416 KB
testcase_04 AC 35 ms
52,096 KB
testcase_05 AC 35 ms
52,224 KB
testcase_06 AC 36 ms
52,224 KB
testcase_07 AC 36 ms
52,736 KB
testcase_08 AC 36 ms
52,224 KB
testcase_09 AC 37 ms
51,968 KB
testcase_10 AC 45 ms
61,184 KB
testcase_11 AC 43 ms
52,352 KB
testcase_12 AC 37 ms
52,608 KB
testcase_13 AC 37 ms
52,224 KB
testcase_14 AC 35 ms
52,096 KB
testcase_15 AC 36 ms
51,968 KB
testcase_16 AC 37 ms
52,224 KB
testcase_17 AC 35 ms
52,096 KB
testcase_18 AC 36 ms
52,096 KB
testcase_19 AC 37 ms
52,736 KB
testcase_20 AC 40 ms
52,608 KB
testcase_21 AC 39 ms
52,096 KB
testcase_22 AC 44 ms
58,240 KB
testcase_23 AC 36 ms
52,096 KB
testcase_24 AC 36 ms
51,968 KB
testcase_25 AC 986 ms
124,416 KB
testcase_26 AC 728 ms
109,440 KB
testcase_27 AC 683 ms
118,784 KB
testcase_28 AC 186 ms
83,628 KB
testcase_29 AC 1,036 ms
126,848 KB
testcase_30 AC 755 ms
109,564 KB
testcase_31 AC 489 ms
104,064 KB
testcase_32 AC 59 ms
67,072 KB
testcase_33 AC 93 ms
82,304 KB
testcase_34 AC 182 ms
93,696 KB
testcase_35 AC 567 ms
105,728 KB
testcase_36 AC 117 ms
84,736 KB
testcase_37 AC 233 ms
100,224 KB
testcase_38 AC 174 ms
81,536 KB
testcase_39 AC 672 ms
108,416 KB
testcase_40 AC 358 ms
91,520 KB
testcase_41 AC 580 ms
105,108 KB
testcase_42 AC 124 ms
79,488 KB
testcase_43 AC 124 ms
78,848 KB
testcase_44 AC 280 ms
86,656 KB
testcase_45 AC 752 ms
137,216 KB
testcase_46 AC 930 ms
156,544 KB
testcase_47 TLE -
testcase_48 AC 725 ms
142,376 KB
testcase_49 TLE -
testcase_50 AC 959 ms
167,248 KB
testcase_51 AC 1,849 ms
211,940 KB
testcase_52 AC 2,150 ms
221,304 KB
testcase_53 TLE -
testcase_54 TLE -
権限があれば一括ダウンロードができます

ソースコード

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