結果

問題 No.807 umg tours
ユーザー yuruhiya
提出日時 2020-09-06 10:48:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 542 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 373,788 KB
最終ジャッジ日時 2025-03-13 15:20:35
合計ジャッジ時間 56,432 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

from numpy import*
from scipy.sparse import*
from sys import stdin
def solve():
    n,m=map(int,stdin.readline().split())
    e=[]
    for i in range(m):
        a,b,c=map(int,stdin.readline().split())
        for _ in [0,0]:
            e.append([a,b,c])
            e.append([a,b+n,0])
            e.append([a+n,b+n,c])
            a,b=b,a
    edge=array(e,int64).T
    graph=csr_matrix((edge[2],edge[:2]-1),(n+n,n+n))
    dist=csgraph.dijkstra(graph,True,0)
    for i in range(n):
        print(int(dist[i]+min(dist[i],dist[i+n])))
solve()
0