結果
問題 | No.2646 Cycle Maze |
ユーザー |
![]() |
提出日時 | 2024-02-26 12:26:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,073 bytes |
コンパイル時間 | 401 ms |
コンパイル使用メモリ | 82,640 KB |
実行使用メモリ | 304,464 KB |
最終ジャッジ日時 | 2024-09-29 11:36:55 |
合計ジャッジ時間 | 15,546 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 47 WA * 4 |
ソースコード
import sysinput = sys.stdin.readlinefrom collections import *M = 605def f(h, w, t):return h * W * M + w * M + tdef g(v):t = v % Mv //= Mh, w = divmod(v, W)return h, w, tH, 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 - 1A = []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)] = 1dx = [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:breakif 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:continueb = (A[x][y] - t - 1) % (A[x][y] + 1)if b == 0 or seen[f(x, y, t+1)]:continueseen[f(x, y, t+1)] = 1Q.append(f(x, y, t+1))print("No")