結果

問題 No.807 umg tours
ユーザー yuruhiyayuruhiya
提出日時 2020-09-06 10:48:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,261 ms / 4,000 ms
コード長 542 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 302,968 KB
最終ジャッジ日時 2023-08-19 13:38:00
合計ジャッジ時間 28,080 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 210 ms
43,576 KB
testcase_01 AC 210 ms
43,636 KB
testcase_02 AC 216 ms
44,192 KB
testcase_03 AC 213 ms
43,852 KB
testcase_04 AC 212 ms
43,416 KB
testcase_05 AC 212 ms
43,520 KB
testcase_06 AC 215 ms
44,036 KB
testcase_07 AC 211 ms
43,968 KB
testcase_08 AC 214 ms
43,292 KB
testcase_09 AC 208 ms
43,312 KB
testcase_10 AC 210 ms
43,472 KB
testcase_11 AC 1,697 ms
266,264 KB
testcase_12 AC 1,287 ms
187,036 KB
testcase_13 AC 1,817 ms
261,052 KB
testcase_14 AC 902 ms
133,896 KB
testcase_15 AC 746 ms
116,688 KB
testcase_16 AC 2,029 ms
279,916 KB
testcase_17 AC 2,252 ms
302,588 KB
testcase_18 AC 2,241 ms
302,884 KB
testcase_19 AC 2,261 ms
302,968 KB
testcase_20 AC 1,289 ms
165,024 KB
testcase_21 AC 1,342 ms
170,056 KB
testcase_22 AC 654 ms
98,020 KB
testcase_23 AC 531 ms
87,020 KB
testcase_24 AC 1,610 ms
235,316 KB
testcase_25 AC 2,222 ms
302,336 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())
        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