結果
| 問題 |
No.2179 Planet Traveler
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:36:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,008 bytes |
| コンパイル時間 | 127 ms |
| コンパイル使用メモリ | 82,372 KB |
| 実行使用メモリ | 124,252 KB |
| 最終ジャッジ日時 | 2025-03-31 17:37:18 |
| 合計ジャッジ時間 | 5,006 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 WA * 1 |
ソースコード
import math
import heapq
n = int(input())
nodes = []
for _ in range(n):
x, y, t = map(int, input().split())
r = math.hypot(x, y)
nodes.append((x, y, t, r))
adj = [[] for _ in range(n + 1)] # 1-based indexing
for i in range(n):
x1, y1, t1, r1 = nodes[i]
for j in range(i + 1, n):
x2, y2, t2, r2 = nodes[j]
if t1 != t2:
s_ij = (r1 - r2) ** 2
else:
dx = x1 - x2
dy = y1 - y2
s_ij = dx * dx + dy * dy
adj[i + 1].append((j + 1, s_ij))
adj[j + 1].append((i + 1, s_ij))
INF = float('inf')
dist = [INF] * (n + 1)
dist[1] = 0.0
heap = []
heapq.heappush(heap, (0.0, 1))
while heap:
current_max, u = heapq.heappop(heap)
if u == n:
break
if current_max > dist[u]:
continue
for v, s in adj[u]:
new_max = max(current_max, s)
if new_max < dist[v]:
dist[v] = new_max
heapq.heappush(heap, (new_max, v))
ans = math.ceil(dist[n])
print(ans)
lam6er