結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
62,560 KB
testcase_01 AC 43 ms
55,648 KB
testcase_02 AC 44 ms
54,252 KB
testcase_03 AC 44 ms
55,776 KB
testcase_04 AC 44 ms
54,636 KB
testcase_05 AC 43 ms
55,660 KB
testcase_06 AC 42 ms
53,992 KB
testcase_07 AC 47 ms
54,648 KB
testcase_08 AC 45 ms
54,688 KB
testcase_09 AC 43 ms
54,628 KB
testcase_10 AC 43 ms
54,444 KB
testcase_11 AC 44 ms
54,304 KB
testcase_12 AC 42 ms
55,940 KB
testcase_13 AC 44 ms
54,364 KB
testcase_14 AC 45 ms
56,016 KB
testcase_15 AC 45 ms
54,644 KB
testcase_16 AC 49 ms
61,724 KB
testcase_17 AC 43 ms
55,084 KB
testcase_18 AC 43 ms
54,908 KB
testcase_19 AC 43 ms
55,416 KB
testcase_20 AC 43 ms
54,216 KB
testcase_21 AC 43 ms
55,580 KB
testcase_22 AC 43 ms
55,636 KB
testcase_23 AC 44 ms
54,600 KB
testcase_24 AC 44 ms
55,180 KB
testcase_25 AC 42 ms
55,864 KB
testcase_26 AC 44 ms
54,792 KB
testcase_27 AC 44 ms
54,660 KB
testcase_28 AC 43 ms
54,980 KB
testcase_29 AC 44 ms
56,084 KB
testcase_30 AC 43 ms
54,464 KB
testcase_31 AC 44 ms
54,436 KB
testcase_32 AC 44 ms
55,112 KB
testcase_33 AC 43 ms
54,996 KB
testcase_34 AC 43 ms
55,004 KB
testcase_35 AC 43 ms
54,056 KB
testcase_36 AC 43 ms
54,772 KB
testcase_37 AC 43 ms
55,388 KB
testcase_38 AC 43 ms
55,028 KB
testcase_39 AC 43 ms
55,768 KB
testcase_40 AC 52 ms
62,856 KB
testcase_41 AC 52 ms
63,296 KB
testcase_42 AC 51 ms
62,628 KB
testcase_43 AC 52 ms
62,196 KB
testcase_44 AC 52 ms
62,908 KB
testcase_45 AC 53 ms
63,676 KB
testcase_46 AC 51 ms
61,936 KB
testcase_47 AC 52 ms
62,052 KB
testcase_48 AC 56 ms
64,520 KB
testcase_49 AC 51 ms
61,744 KB
testcase_50 AC 52 ms
61,480 KB
testcase_51 AC 51 ms
62,452 KB
testcase_52 AC 50 ms
61,592 KB
testcase_53 AC 78 ms
74,416 KB
testcase_54 AC 50 ms
61,848 KB
testcase_55 AC 52 ms
62,112 KB
testcase_56 AC 55 ms
62,848 KB
testcase_57 AC 53 ms
62,908 KB
testcase_58 AC 54 ms
62,604 KB
testcase_59 AC 52 ms
63,112 KB
testcase_60 AC 154 ms
77,284 KB
testcase_61 AC 43 ms
55,028 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

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