結果
| 問題 | No.3393 Move on Highway |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-23 22:35:43 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,721 ms / 3,000 ms |
| コード長 | 757 bytes |
| 記録 | |
| コンパイル時間 | 141 ms |
| コンパイル使用メモリ | 85,632 KB |
| 実行使用メモリ | 164,376 KB |
| 最終ジャッジ日時 | 2026-03-23 22:36:23 |
| 合計ジャッジ時間 | 37,668 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
import heapq
n,m,c=map(int,input().split())
v=[[] for i in range(n)]
for i in range(m):
q,w,e=map(int,input().split())
q-=1;w-=1
v[q].append((w,e));v[w].append((q,e))
x=[];heapq.heappush(x,(0,0))
y=[1<<60]*n;y[0]=0
while x:
q,w=heapq.heappop(x)
if y[w]<q:
continue
for i,j in v[w]:
if y[i]>q+j+c:
y[i]=q+j+c
heapq.heappush(x,(y[i],i))
a,b=[1<<60]*n,[1<<60]*n
a[-1]=0;b[-1]=0
x=[];heapq.heappush(x,(0,n-1,0))
while x:
q,w,e=heapq.heappop(x)
if a[w]<q and b[w]<q-e:
continue
for i,j in v[w]:
if q+c+j-max(j,e)<b[i]:
b[i]=q+c+j-max(j,e)
heapq.heappush(x,(q+c+j,i,max(j,e)))
if q+c+j<a[i]:
a[i]=q+c+j
heapq.heappush(x,(a[i],i,max(e,j)))
for i in range(1,n):
print(min(y[-1],y[i]+b[i]))