結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-02-27 16:15:54 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 925 bytes |
| コンパイル時間 | 440 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 333,996 KB |
| 最終ジャッジ日時 | 2024-11-23 19:51:40 |
| 合計ジャッジ時間 | 40,796 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 TLE * 1 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop, heappush
# %%
N, M = map(int, readline().split())
m = map(int, read().split())
ABC = zip(m, m, m)
# %%
G = [[] for _ in range(N + N + 1)]
for a, b, c in ABC:
G[a].append((b, c))
G[a].append((b + N, 0))
G[a + N].append((b + N, c))
G[b].append((a, c))
G[b].append((a + N, 0))
G[b + N].append((a + N, c))
# %%
INF = 10**18
dist = [INF] * (N + N + 1)
q = [1]
dist[1] = 0
while q:
x = heappop(q)
dv, v = divmod(x, 1 << 20)
if dist[v] > dv:
continue
for w, c in G[v]:
dw = dv + c
if dw >= dist[w]:
continue
dist[w] = dw
heappush(q, (dw << 20) + w)
# %%
dist[1 + N] = 0
answer = (x + y for x, y in zip(dist[1:], dist[1 + N:]))
print('\n'.join(map(str, answer)))
maspy