結果

問題 No.1344 Typical Shortest Path Sum
ユーザー lloyzlloyz
提出日時 2023-04-20 00:11:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 75,532 KB
最終ジャッジ日時 2024-04-23 03:27:24
合計ジャッジ時間 5,191 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,300 KB
testcase_01 AC 37 ms
53,000 KB
testcase_02 AC 37 ms
53,280 KB
testcase_03 AC 45 ms
61,820 KB
testcase_04 AC 39 ms
61,196 KB
testcase_05 AC 36 ms
52,728 KB
testcase_06 AC 33 ms
52,140 KB
testcase_07 AC 33 ms
53,324 KB
testcase_08 AC 33 ms
53,104 KB
testcase_09 AC 37 ms
52,772 KB
testcase_10 AC 35 ms
52,192 KB
testcase_11 AC 36 ms
53,184 KB
testcase_12 AC 37 ms
52,636 KB
testcase_13 AC 36 ms
52,200 KB
testcase_14 AC 33 ms
52,880 KB
testcase_15 AC 33 ms
53,740 KB
testcase_16 AC 46 ms
62,676 KB
testcase_17 AC 33 ms
52,836 KB
testcase_18 AC 34 ms
52,812 KB
testcase_19 AC 33 ms
52,340 KB
testcase_20 AC 33 ms
53,424 KB
testcase_21 AC 33 ms
53,032 KB
testcase_22 AC 32 ms
52,028 KB
testcase_23 AC 33 ms
53,616 KB
testcase_24 AC 34 ms
52,616 KB
testcase_25 AC 33 ms
53,572 KB
testcase_26 AC 33 ms
52,196 KB
testcase_27 AC 32 ms
53,128 KB
testcase_28 AC 33 ms
53,592 KB
testcase_29 AC 33 ms
52,544 KB
testcase_30 AC 33 ms
52,460 KB
testcase_31 AC 33 ms
52,616 KB
testcase_32 AC 33 ms
53,056 KB
testcase_33 AC 33 ms
52,432 KB
testcase_34 AC 34 ms
54,076 KB
testcase_35 AC 33 ms
53,480 KB
testcase_36 AC 34 ms
52,852 KB
testcase_37 AC 34 ms
52,984 KB
testcase_38 AC 34 ms
52,560 KB
testcase_39 AC 32 ms
52,964 KB
testcase_40 AC 52 ms
66,400 KB
testcase_41 AC 55 ms
65,980 KB
testcase_42 AC 51 ms
64,560 KB
testcase_43 AC 52 ms
64,432 KB
testcase_44 AC 50 ms
64,844 KB
testcase_45 AC 52 ms
64,988 KB
testcase_46 AC 52 ms
66,124 KB
testcase_47 AC 49 ms
64,136 KB
testcase_48 AC 53 ms
66,336 KB
testcase_49 AC 51 ms
64,032 KB
testcase_50 AC 51 ms
64,980 KB
testcase_51 AC 56 ms
65,472 KB
testcase_52 AC 53 ms
65,456 KB
testcase_53 AC 57 ms
65,620 KB
testcase_54 AC 50 ms
64,148 KB
testcase_55 AC 50 ms
64,072 KB
testcase_56 AC 55 ms
66,244 KB
testcase_57 AC 53 ms
65,984 KB
testcase_58 AC 55 ms
65,576 KB
testcase_59 AC 53 ms
65,332 KB
testcase_60 AC 43 ms
61,092 KB
testcase_61 AC 34 ms
53,684 KB
testcase_62 AC 69 ms
74,804 KB
testcase_63 AC 47 ms
65,000 KB
testcase_64 AC 50 ms
65,152 KB
testcase_65 AC 70 ms
74,640 KB
testcase_66 AC 68 ms
75,532 KB
testcase_67 AC 76 ms
74,188 KB
testcase_68 AC 46 ms
63,308 KB
testcase_69 AC 45 ms
63,336 KB
testcase_70 AC 41 ms
60,824 KB
testcase_71 AC 33 ms
52,192 KB
testcase_72 AC 34 ms
52,812 KB
testcase_73 AC 34 ms
53,564 KB
testcase_74 AC 37 ms
53,520 KB
testcase_75 AC 36 ms
52,992 KB
testcase_76 AC 33 ms
52,900 KB
testcase_77 AC 34 ms
52,332 KB
testcase_78 AC 34 ms
53,312 KB
testcase_79 AC 44 ms
62,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
INF = 10**18
DP = [[INF for _ in range(n)] for _ in range(n)]
for i in range(n):
    DP[i][i] = 0
for _ in range(m):
    s, t, d = map(int, input().split())
    DP[s - 1][t - 1] = min(DP[s - 1][t - 1], d)

for j in range(n):
    for i in range(n):
        for k in range(n):
            if DP[i][j] != INF and DP[j][k] != INF:
                DP[i][k] = min(DP[i][k], DP[i][j] + DP[j][k])

for i in range(n):
    ans = 0
    for j in range(n):
        if DP[i][j] != INF:
            ans += DP[i][j]
    print(ans)
0