結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
61,516 KB
testcase_01 AC 45 ms
55,096 KB
testcase_02 AC 44 ms
55,952 KB
testcase_03 AC 45 ms
55,192 KB
testcase_04 AC 44 ms
55,316 KB
testcase_05 AC 45 ms
55,116 KB
testcase_06 AC 49 ms
55,876 KB
testcase_07 AC 45 ms
55,168 KB
testcase_08 AC 44 ms
55,096 KB
testcase_09 AC 52 ms
54,752 KB
testcase_10 AC 45 ms
54,364 KB
testcase_11 AC 47 ms
56,228 KB
testcase_12 AC 46 ms
54,316 KB
testcase_13 AC 44 ms
54,968 KB
testcase_14 AC 46 ms
56,548 KB
testcase_15 AC 44 ms
55,440 KB
testcase_16 AC 53 ms
62,312 KB
testcase_17 AC 45 ms
54,416 KB
testcase_18 AC 44 ms
56,048 KB
testcase_19 AC 45 ms
54,396 KB
testcase_20 AC 45 ms
54,380 KB
testcase_21 AC 47 ms
54,192 KB
testcase_22 AC 46 ms
54,688 KB
testcase_23 AC 46 ms
54,512 KB
testcase_24 AC 45 ms
56,060 KB
testcase_25 AC 46 ms
55,712 KB
testcase_26 AC 46 ms
54,372 KB
testcase_27 AC 46 ms
54,684 KB
testcase_28 AC 44 ms
54,784 KB
testcase_29 AC 47 ms
55,624 KB
testcase_30 AC 44 ms
54,720 KB
testcase_31 AC 46 ms
55,312 KB
testcase_32 AC 44 ms
54,624 KB
testcase_33 AC 48 ms
55,456 KB
testcase_34 AC 44 ms
55,004 KB
testcase_35 AC 44 ms
55,312 KB
testcase_36 AC 45 ms
54,916 KB
testcase_37 AC 45 ms
54,972 KB
testcase_38 AC 47 ms
54,852 KB
testcase_39 AC 47 ms
56,116 KB
testcase_40 AC 54 ms
63,020 KB
testcase_41 AC 54 ms
62,688 KB
testcase_42 AC 58 ms
63,284 KB
testcase_43 AC 51 ms
62,220 KB
testcase_44 AC 52 ms
62,388 KB
testcase_45 AC 55 ms
63,824 KB
testcase_46 AC 54 ms
62,744 KB
testcase_47 AC 54 ms
63,500 KB
testcase_48 AC 56 ms
63,956 KB
testcase_49 AC 53 ms
63,024 KB
testcase_50 AC 53 ms
62,144 KB
testcase_51 AC 54 ms
62,412 KB
testcase_52 AC 53 ms
62,324 KB
testcase_53 AC 86 ms
74,532 KB
testcase_54 AC 56 ms
61,916 KB
testcase_55 AC 53 ms
63,000 KB
testcase_56 AC 55 ms
63,888 KB
testcase_57 AC 55 ms
63,068 KB
testcase_58 AC 59 ms
63,536 KB
testcase_59 AC 56 ms
64,472 KB
testcase_60 AC 162 ms
77,444 KB
testcase_61 AC 45 ms
56,852 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

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)
0