結果
| 問題 | No.807 umg tours |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2019-03-22 22:18:23 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2,410 ms / 4,000 ms |
| + 674µs | |
| コード長 | 978 bytes |
| 記録 | |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 120,832 KB |
| 最終ジャッジ日時 | 2026-09-28 18:25:17 |
| 合計ジャッジ時間 | 22,611 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
E=[list(map(int,input().split())) for i in range(M)]
EDGE=[[] for i in range(N+1)]
for x,y,c in E:
EDGE[x].append([y,c])
EDGE[y].append([x,c])
MIN=[10**15]*(N+1)
MIN2=[10**15]*(N+1)
MIN[1]=0
MIN2[1]=0
from collections import deque
QUE=deque([[1,0,0]])
while QUE:
town,dist,maxdist=QUE.popleft()
if MIN[town]<dist and MIN2[town]<dist-maxdist:
continue
for to,cost in EDGE[town]:
Flag=0
if maxdist>cost:
maxdist_town=maxdist
else:
maxdist_town=cost
if MIN[to]>dist+cost:
MIN[to]=dist+cost
Flag=1
if MIN2[to]>dist+cost-maxdist_town:
MIN2[to]=dist+cost-maxdist_town
Flag=1
if Flag:
QUE.append([to,dist+cost,maxdist_town])
for i in range(1,N+1):
print(MIN[i]+MIN2[i])
titia