結果

問題 No.1344 Typical Shortest Path Sum
ユーザー lloyzlloyz
提出日時 2023-04-20 00:06:03
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 900 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 84,088 KB
最終ジャッジ日時 2024-04-23 03:22:12
合計ジャッジ時間 7,936 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
61,532 KB
testcase_01 AC 43 ms
54,664 KB
testcase_02 AC 43 ms
55,888 KB
testcase_03 AC 44 ms
56,212 KB
testcase_04 AC 43 ms
54,908 KB
testcase_05 AC 43 ms
54,752 KB
testcase_06 AC 44 ms
54,876 KB
testcase_07 AC 44 ms
54,308 KB
testcase_08 AC 43 ms
54,552 KB
testcase_09 AC 45 ms
54,728 KB
testcase_10 AC 44 ms
54,740 KB
testcase_11 AC 43 ms
54,852 KB
testcase_12 AC 41 ms
54,468 KB
testcase_13 AC 42 ms
55,860 KB
testcase_14 AC 41 ms
55,344 KB
testcase_15 AC 43 ms
54,856 KB
testcase_16 AC 47 ms
61,752 KB
testcase_17 AC 42 ms
54,996 KB
testcase_18 AC 42 ms
54,448 KB
testcase_19 AC 44 ms
55,864 KB
testcase_20 AC 41 ms
54,548 KB
testcase_21 AC 42 ms
55,572 KB
testcase_22 AC 42 ms
54,944 KB
testcase_23 AC 43 ms
55,644 KB
testcase_24 AC 44 ms
54,972 KB
testcase_25 AC 43 ms
55,032 KB
testcase_26 AC 43 ms
54,600 KB
testcase_27 AC 43 ms
54,408 KB
testcase_28 AC 43 ms
54,504 KB
testcase_29 AC 43 ms
54,512 KB
testcase_30 AC 42 ms
55,640 KB
testcase_31 AC 43 ms
54,860 KB
testcase_32 AC 43 ms
54,264 KB
testcase_33 AC 43 ms
54,856 KB
testcase_34 AC 43 ms
54,868 KB
testcase_35 AC 44 ms
54,380 KB
testcase_36 AC 43 ms
54,992 KB
testcase_37 AC 44 ms
54,796 KB
testcase_38 AC 43 ms
54,908 KB
testcase_39 AC 43 ms
55,644 KB
testcase_40 AC 53 ms
61,836 KB
testcase_41 AC 52 ms
63,688 KB
testcase_42 AC 49 ms
62,220 KB
testcase_43 AC 52 ms
62,648 KB
testcase_44 AC 50 ms
62,852 KB
testcase_45 AC 51 ms
62,696 KB
testcase_46 AC 53 ms
62,536 KB
testcase_47 AC 54 ms
62,268 KB
testcase_48 AC 54 ms
63,028 KB
testcase_49 AC 50 ms
62,120 KB
testcase_50 AC 51 ms
62,224 KB
testcase_51 AC 52 ms
62,936 KB
testcase_52 AC 49 ms
62,108 KB
testcase_53 AC 75 ms
73,832 KB
testcase_54 AC 50 ms
61,652 KB
testcase_55 AC 51 ms
63,324 KB
testcase_56 AC 53 ms
63,676 KB
testcase_57 AC 53 ms
62,600 KB
testcase_58 AC 53 ms
63,016 KB
testcase_59 AC 54 ms
62,488 KB
testcase_60 AC 134 ms
76,988 KB
testcase_61 AC 44 ms
55,032 KB
testcase_62 TLE -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush
from collections import defaultdict
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    G = defaultdict(list)
    for _ in range(m):
        s, t, d = map(int, input().split())
        s -= 1
        t -= 1
        G[s].append((t, d))

    INF = 10**18
    for i in range(n):
        DP = [INF for _ in range(n)]
        DP[i] = 0
        H = [(0, i)]
        while H:
            cc, ci = heappop(H)
            if cc > DP[ci]:
                continue
            for ni, dc in G[ci]:
                nc = cc + dc
                if nc >= DP[ni]:
                    continue
                DP[ni] = nc
                heappush(H, (nc, ni))
        ans = 0
        for i in range(n):
            if DP[i] == INF:
                continue
            ans += DP[i]
        print(ans)

if __name__ == '__main__':
    main()
0