結果

問題 No.2646 Cycle Maze
ユーザー rlangevinrlangevin
提出日時 2024-02-26 12:26:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,073 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 303,656 KB
最終ジャッジ日時 2024-02-26 12:26:42
合計ジャッジ時間 17,590 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,600 KB
testcase_01 AC 39 ms
55,600 KB
testcase_02 AC 39 ms
55,600 KB
testcase_03 AC 40 ms
55,600 KB
testcase_04 AC 39 ms
55,600 KB
testcase_05 AC 40 ms
55,600 KB
testcase_06 WA -
testcase_07 AC 40 ms
55,600 KB
testcase_08 AC 39 ms
55,600 KB
testcase_09 AC 39 ms
55,600 KB
testcase_10 AC 44 ms
55,728 KB
testcase_11 AC 40 ms
55,728 KB
testcase_12 WA -
testcase_13 AC 39 ms
55,600 KB
testcase_14 AC 39 ms
55,600 KB
testcase_15 AC 39 ms
55,600 KB
testcase_16 WA -
testcase_17 AC 42 ms
55,600 KB
testcase_18 WA -
testcase_19 AC 44 ms
55,728 KB
testcase_20 AC 41 ms
55,728 KB
testcase_21 AC 40 ms
55,728 KB
testcase_22 AC 39 ms
55,600 KB
testcase_23 AC 39 ms
55,600 KB
testcase_24 AC 40 ms
55,600 KB
testcase_25 AC 96 ms
123,548 KB
testcase_26 AC 124 ms
126,028 KB
testcase_27 AC 323 ms
175,764 KB
testcase_28 AC 85 ms
90,380 KB
testcase_29 AC 90 ms
124,492 KB
testcase_30 AC 101 ms
115,676 KB
testcase_31 AC 64 ms
125,704 KB
testcase_32 AC 58 ms
70,080 KB
testcase_33 AC 110 ms
144,976 KB
testcase_34 AC 207 ms
177,928 KB
testcase_35 AC 208 ms
131,096 KB
testcase_36 AC 133 ms
139,736 KB
testcase_37 AC 141 ms
191,780 KB
testcase_38 AC 63 ms
77,976 KB
testcase_39 AC 115 ms
115,036 KB
testcase_40 AC 52 ms
88,244 KB
testcase_41 AC 128 ms
128,188 KB
testcase_42 AC 94 ms
88,604 KB
testcase_43 AC 67 ms
77,100 KB
testcase_44 AC 96 ms
88,848 KB
testcase_45 AC 690 ms
275,684 KB
testcase_46 AC 528 ms
275,556 KB
testcase_47 AC 117 ms
256,288 KB
testcase_48 AC 361 ms
269,288 KB
testcase_49 AC 465 ms
272,484 KB
testcase_50 AC 1,099 ms
291,684 KB
testcase_51 AC 2,274 ms
303,060 KB
testcase_52 AC 2,224 ms
302,908 KB
testcase_53 AC 2,218 ms
302,828 KB
testcase_54 AC 2,216 ms
303,656 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+1:
        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