結果

問題 No.2646 Cycle Maze
ユーザー rlangevinrlangevin
提出日時 2024-02-26 12:30:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,112 ms / 2,500 ms
コード長 1,071 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 303,664 KB
最終ジャッジ日時 2024-02-26 12:30:47
合計ジャッジ時間 16,597 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,600 KB
testcase_01 AC 40 ms
55,600 KB
testcase_02 AC 42 ms
55,600 KB
testcase_03 AC 40 ms
55,600 KB
testcase_04 AC 39 ms
55,600 KB
testcase_05 AC 39 ms
55,600 KB
testcase_06 AC 40 ms
55,600 KB
testcase_07 AC 44 ms
55,600 KB
testcase_08 AC 38 ms
55,600 KB
testcase_09 AC 39 ms
55,600 KB
testcase_10 AC 40 ms
55,728 KB
testcase_11 AC 39 ms
55,728 KB
testcase_12 AC 39 ms
55,728 KB
testcase_13 AC 39 ms
55,600 KB
testcase_14 AC 38 ms
55,600 KB
testcase_15 AC 39 ms
55,600 KB
testcase_16 AC 38 ms
55,600 KB
testcase_17 AC 43 ms
55,600 KB
testcase_18 AC 39 ms
55,600 KB
testcase_19 AC 39 ms
55,728 KB
testcase_20 AC 39 ms
55,728 KB
testcase_21 AC 39 ms
55,728 KB
testcase_22 AC 39 ms
55,600 KB
testcase_23 AC 38 ms
55,600 KB
testcase_24 AC 38 ms
55,600 KB
testcase_25 AC 90 ms
123,544 KB
testcase_26 AC 121 ms
126,024 KB
testcase_27 AC 280 ms
175,760 KB
testcase_28 AC 84 ms
90,376 KB
testcase_29 AC 92 ms
124,488 KB
testcase_30 AC 98 ms
115,672 KB
testcase_31 AC 61 ms
125,704 KB
testcase_32 AC 57 ms
70,076 KB
testcase_33 AC 105 ms
144,976 KB
testcase_34 AC 193 ms
177,796 KB
testcase_35 AC 195 ms
131,092 KB
testcase_36 AC 128 ms
139,732 KB
testcase_37 AC 114 ms
191,776 KB
testcase_38 AC 61 ms
77,972 KB
testcase_39 AC 122 ms
115,032 KB
testcase_40 AC 52 ms
88,244 KB
testcase_41 AC 124 ms
128,184 KB
testcase_42 AC 93 ms
88,600 KB
testcase_43 AC 66 ms
77,096 KB
testcase_44 AC 97 ms
88,844 KB
testcase_45 AC 544 ms
275,676 KB
testcase_46 AC 501 ms
275,552 KB
testcase_47 AC 113 ms
256,288 KB
testcase_48 AC 363 ms
269,284 KB
testcase_49 AC 423 ms
272,480 KB
testcase_50 AC 1,019 ms
291,680 KB
testcase_51 AC 2,093 ms
303,056 KB
testcase_52 AC 2,112 ms
302,908 KB
testcase_53 AC 2,092 ms
302,824 KB
testcase_54 AC 2,108 ms
303,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *
M = 605

def f(h, w, t):
    return h * W * M + w * M + t

def g(v):
    t = v % M
    v //= M
    h, w = divmod(v, W)
    return h, w, t

H, W, T = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
sx, sy, gx, gy = sx - 1, sy - 1, gx - 1, gy - 1
A = []
for i in range(H):
    L = list(input().rstrip())
    L = list(map(int, L))
    A.append(L)
    
seen = [0] * H * W * (M+1)
Q = deque()
Q.append(f(sx, sy, 0))
seen[f(sx, sy, 0)] = 1
dx = [1, 0, -1, 0, 0]
dy = [0, 1, 0, -1, 0]
while Q:
    v = Q.popleft()
    h, w, t = g(v)
    if t == T:
        break
    if h == gx and w == gy:
        print("Yes")
        exit()
        
    for k in range(5):
        x = h + dx[k]
        y = w + dy[k]
        if x < 0 or x > H - 1 or y < 0 or y > W - 1:
            continue
        b = (A[x][y] - t - 1) % (A[x][y] + 1)
        if b == 0 or seen[f(x, y, t+1)]:
            continue
        seen[f(x, y, t+1)] = 1
        Q.append(f(x, y, t+1))
    
print("No")    
0