結果
問題 | No.2695 Warp Zone |
ユーザー |
|
提出日時 | 2024-06-01 14:39:56 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 881 bytes |
コンパイル時間 | 298 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 852,236 KB |
最終ジャッジ日時 | 2024-12-21 23:47:04 |
合計ジャッジ時間 | 9,576 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 MLE * 1 |
other | AC * 5 RE * 16 TLE * 1 MLE * 2 |
ソースコード
from heapq import heapify, heappop, heappushH, W, N = map(int, input().split())D = {}for _ in range(N):a, b, c, d = map(int, input().split())a -= 1; b -= 1; c -= 1; d -= 1D[(a, b)] = (c, d)dist = [10 ** 18] * (H * W)dist[0] = 0pq = [(0, 0)]heapify(pq)dx = [-1, 0, 0, 1]dy = [0, -1, 1, 0]while len(pq) > 0:d, id = heappop(pq)x, y = id // W, id % Wif (x, y) in D:v, w = D[(x, y)]if dist[v * W + w] > dist[id] + 1:dist[v * W + w] = dist[id] + 1heappush(pq, (dist[v * W + w], v * W + w))for i in range(4):nx = x + dx[i]ny = y + dy[i]if 0 > nx or nx >= H or 0 > ny or ny >= W: continueif dist[nx * W + ny] > dist[id] + 1:dist[nx * W + ny] = dist[id] + 1heappush(pq, (dist[nx * W + ny], nx * W + ny))print(dist[(H - 1) * W + (W - 1)])