結果

問題 No.807 umg tours
ユーザー yuruhiya
提出日時 2020-09-06 10:58:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 595 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 361,524 KB
最終ジャッジ日時 2025-01-26 12:40:12
合計ジャッジ時間 58,637 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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=[[]]*(m*6)
    p=0
    for i in range(m):
        a,b,c=map(int,stdin.readline().split())
        a-=1;b-=1
        e[p]=[a,b,c]
        e[p+1]=[a,b+n,0]
        e[p+2]=[a+n,b+n,c]
        e[p+3]=[b,a,c]
        e[p+4]=[b,a+n,0]
        e[p+5]=[b+n,a+n,c]
        p+=6
    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