結果

問題 No.807 umg tours
ユーザー yuruhiyayuruhiya
提出日時 2020-09-06 10:50:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,922 ms / 4,000 ms
コード長 586 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 288,060 KB
最終ジャッジ日時 2023-08-19 13:38:28
合計ジャッジ時間 24,366 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
43,760 KB
testcase_01 AC 181 ms
43,544 KB
testcase_02 AC 189 ms
44,176 KB
testcase_03 AC 179 ms
43,884 KB
testcase_04 AC 179 ms
43,488 KB
testcase_05 AC 176 ms
43,796 KB
testcase_06 AC 181 ms
44,360 KB
testcase_07 AC 183 ms
43,804 KB
testcase_08 AC 174 ms
43,212 KB
testcase_09 AC 178 ms
43,520 KB
testcase_10 AC 177 ms
43,392 KB
testcase_11 AC 1,479 ms
249,956 KB
testcase_12 AC 1,156 ms
180,132 KB
testcase_13 AC 1,580 ms
247,464 KB
testcase_14 AC 758 ms
129,328 KB
testcase_15 AC 638 ms
113,284 KB
testcase_16 AC 1,792 ms
263,796 KB
testcase_17 AC 1,922 ms
288,060 KB
testcase_18 AC 1,890 ms
287,844 KB
testcase_19 AC 1,901 ms
288,048 KB
testcase_20 AC 1,075 ms
163,924 KB
testcase_21 AC 1,103 ms
168,384 KB
testcase_22 AC 554 ms
98,048 KB
testcase_23 AC 452 ms
86,044 KB
testcase_24 AC 1,424 ms
226,488 KB
testcase_25 AC 1,864 ms
288,040 KB
権限があれば一括ダウンロードができます

ソースコード

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