結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 45 ms
61,972 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 36 ms
53,460 KB
testcase_09 AC 38 ms
53,460 KB
testcase_10 AC 40 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 38 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 39 ms
53,460 KB
testcase_22 AC 42 ms
59,588 KB
testcase_23 AC 37 ms
53,460 KB
testcase_24 AC 37 ms
53,460 KB
testcase_25 AC 639 ms
124,040 KB
testcase_26 AC 461 ms
109,228 KB
testcase_27 AC 479 ms
118,544 KB
testcase_28 AC 148 ms
83,296 KB
testcase_29 AC 692 ms
126,208 KB
testcase_30 AC 488 ms
109,088 KB
testcase_31 AC 340 ms
103,716 KB
testcase_32 AC 55 ms
66,528 KB
testcase_33 AC 85 ms
81,132 KB
testcase_34 AC 165 ms
93,696 KB
testcase_35 WA -
testcase_36 AC 97 ms
81,152 KB
testcase_37 AC 211 ms
99,708 KB
testcase_38 AC 136 ms
81,020 KB
testcase_39 AC 445 ms
108,484 KB
testcase_40 AC 250 ms
90,956 KB
testcase_41 AC 401 ms
104,176 KB
testcase_42 AC 111 ms
79,096 KB
testcase_43 AC 105 ms
78,412 KB
testcase_44 AC 198 ms
86,600 KB
testcase_45 AC 550 ms
137,004 KB
testcase_46 AC 713 ms
156,380 KB
testcase_47 AC 1,953 ms
247,956 KB
testcase_48 AC 546 ms
141,380 KB
testcase_49 AC 1,949 ms
252,016 KB
testcase_50 AC 688 ms
166,688 KB
testcase_51 AC 1,212 ms
211,380 KB
testcase_52 AC 1,363 ms
221,196 KB
testcase_53 AC 1,787 ms
263,952 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, 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(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