結果

問題 No.807 umg tours
ユーザー yuruhiya
提出日時 2020-09-06 10:50:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 3,577 ms / 4,000 ms
コード長 586 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 298,940 KB
最終ジャッジ日時 2024-11-29 06:51:08
合計ジャッジ時間 52,925 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 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())
        a-=1;b-=1
        e.append([a,b,c])
        e.append([a,b+n,0])
        e.append([a+n,b+n,c])
        e.append([b,a,c])
        e.append([b,a+n,0])
        e.append([b+n,a+n,c])
    edge=array(e,int64).T
    graph=csr_matrix((edge[2],edge[:2]),(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