結果
| 問題 | No.1601 With Animals into Institute |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-02-21 05:21:11 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,976 ms / 3,000 ms |
| コード長 | 711 bytes |
| 記録 | |
| コンパイル時間 | 380 ms |
| コンパイル使用メモリ | 82,228 KB |
| 実行使用メモリ | 168,476 KB |
| 最終ジャッジ日時 | 2026-02-21 05:21:40 |
| 合計ジャッジ時間 | 28,830 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
N,M=list(map(int,input().split()))
E=[[] for i in range(N+1)]
for i in range(M):
a,b,c,x=list(map(int,input().split()))
E[a].append((b,c,x))
E[b].append((a,c,x))
DIS=[[1<<63]*(M+1) for i in range(2)]
DIS[0][N]=0
Q=[(0,N,0)]
while Q:
distance,town,ind=heappop(Q)
if DIS[ind][town]!=distance:
continue
for to,cost,com in E[town]:
if com==0:
toind=ind
else:
toind=1
if DIS[toind][to]>distance+cost:
DIS[toind][to]=distance+cost
heappush(Q,(distance+cost,to,toind))
for i in range(1,N):
print(DIS[1][i])
titia