結果

問題 No.1344 Typical Shortest Path Sum
ユーザー MitarushiMitarushi
提出日時 2021-01-16 13:28:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 77,872 KB
最終ジャッジ日時 2023-08-18 09:56:40
合計ジャッジ時間 10,254 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,032 KB
testcase_01 AC 71 ms
71,304 KB
testcase_02 AC 68 ms
71,280 KB
testcase_03 AC 121 ms
76,492 KB
testcase_04 AC 81 ms
76,384 KB
testcase_05 AC 70 ms
71,324 KB
testcase_06 AC 71 ms
71,348 KB
testcase_07 AC 69 ms
70,928 KB
testcase_08 AC 70 ms
71,420 KB
testcase_09 AC 72 ms
70,936 KB
testcase_10 AC 69 ms
71,228 KB
testcase_11 AC 72 ms
70,936 KB
testcase_12 AC 72 ms
71,304 KB
testcase_13 AC 69 ms
71,364 KB
testcase_14 AC 71 ms
71,264 KB
testcase_15 AC 71 ms
71,260 KB
testcase_16 AC 108 ms
77,396 KB
testcase_17 AC 72 ms
71,324 KB
testcase_18 AC 71 ms
71,284 KB
testcase_19 AC 73 ms
71,284 KB
testcase_20 AC 70 ms
71,132 KB
testcase_21 AC 69 ms
71,456 KB
testcase_22 AC 71 ms
71,120 KB
testcase_23 AC 73 ms
71,396 KB
testcase_24 AC 71 ms
71,112 KB
testcase_25 AC 69 ms
71,100 KB
testcase_26 AC 70 ms
71,560 KB
testcase_27 AC 69 ms
71,232 KB
testcase_28 AC 75 ms
71,136 KB
testcase_29 AC 71 ms
71,392 KB
testcase_30 AC 70 ms
71,420 KB
testcase_31 AC 70 ms
71,104 KB
testcase_32 AC 72 ms
71,224 KB
testcase_33 AC 71 ms
71,560 KB
testcase_34 AC 71 ms
71,452 KB
testcase_35 AC 70 ms
71,352 KB
testcase_36 AC 72 ms
71,312 KB
testcase_37 AC 70 ms
71,296 KB
testcase_38 AC 71 ms
71,104 KB
testcase_39 AC 71 ms
71,356 KB
testcase_40 AC 131 ms
77,408 KB
testcase_41 AC 140 ms
77,292 KB
testcase_42 AC 132 ms
77,380 KB
testcase_43 AC 128 ms
77,500 KB
testcase_44 AC 128 ms
77,352 KB
testcase_45 AC 129 ms
77,732 KB
testcase_46 AC 131 ms
77,644 KB
testcase_47 AC 136 ms
77,652 KB
testcase_48 AC 135 ms
77,460 KB
testcase_49 AC 124 ms
77,712 KB
testcase_50 AC 129 ms
77,496 KB
testcase_51 AC 131 ms
77,476 KB
testcase_52 AC 127 ms
77,732 KB
testcase_53 AC 134 ms
77,184 KB
testcase_54 AC 125 ms
77,500 KB
testcase_55 AC 135 ms
77,484 KB
testcase_56 AC 132 ms
77,316 KB
testcase_57 AC 125 ms
77,696 KB
testcase_58 AC 137 ms
77,664 KB
testcase_59 AC 133 ms
77,432 KB
testcase_60 AC 81 ms
75,908 KB
testcase_61 AC 70 ms
71,280 KB
testcase_62 AC 109 ms
77,548 KB
testcase_63 AC 85 ms
76,272 KB
testcase_64 AC 86 ms
76,372 KB
testcase_65 AC 109 ms
77,684 KB
testcase_66 AC 108 ms
77,872 KB
testcase_67 AC 106 ms
77,720 KB
testcase_68 AC 83 ms
76,404 KB
testcase_69 AC 81 ms
76,304 KB
testcase_70 AC 85 ms
76,008 KB
testcase_71 AC 69 ms
71,232 KB
testcase_72 AC 70 ms
71,284 KB
testcase_73 AC 69 ms
71,132 KB
testcase_74 AC 70 ms
71,060 KB
testcase_75 AC 69 ms
71,428 KB
testcase_76 AC 71 ms
71,104 KB
testcase_77 AC 69 ms
71,360 KB
testcase_78 AC 71 ms
71,300 KB
testcase_79 AC 86 ms
76,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())

inf = float("inf")

dist = [[inf]*n for _ in range(n)]
for i in range(n):
    dist[i][i] = 0

for _ in range(m):
    s, t, d = map(int, input().split())
    s -= 1
    t -= 1
    dist[s][t] = min(dist[s][t], d)

for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k], dist[j][i]+dist[i][k])


for i in range(n):
    ans = 0
    for j in range(n):
        if dist[i][j] != inf and i != j:
            ans += dist[i][j]
    print(ans)
0