結果

問題 No.1344 Typical Shortest Path Sum
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2021-01-16 14:49:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 77,788 KB
最終ジャッジ日時 2023-08-18 12:02:38
合計ジャッジ時間 10,258 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,244 KB
testcase_01 AC 69 ms
71,256 KB
testcase_02 AC 68 ms
70,956 KB
testcase_03 AC 112 ms
76,324 KB
testcase_04 AC 75 ms
76,264 KB
testcase_05 AC 65 ms
71,208 KB
testcase_06 AC 66 ms
71,276 KB
testcase_07 AC 66 ms
71,212 KB
testcase_08 AC 67 ms
71,304 KB
testcase_09 AC 68 ms
71,224 KB
testcase_10 AC 66 ms
71,224 KB
testcase_11 AC 66 ms
70,920 KB
testcase_12 AC 67 ms
71,252 KB
testcase_13 AC 67 ms
71,216 KB
testcase_14 AC 65 ms
71,048 KB
testcase_15 AC 66 ms
71,384 KB
testcase_16 AC 128 ms
77,196 KB
testcase_17 AC 70 ms
70,928 KB
testcase_18 AC 69 ms
71,076 KB
testcase_19 AC 68 ms
71,388 KB
testcase_20 AC 66 ms
71,248 KB
testcase_21 AC 66 ms
70,932 KB
testcase_22 AC 67 ms
71,192 KB
testcase_23 AC 68 ms
71,252 KB
testcase_24 AC 67 ms
71,380 KB
testcase_25 AC 66 ms
71,248 KB
testcase_26 AC 67 ms
71,224 KB
testcase_27 AC 65 ms
71,380 KB
testcase_28 AC 68 ms
70,916 KB
testcase_29 AC 67 ms
71,404 KB
testcase_30 AC 67 ms
71,388 KB
testcase_31 AC 67 ms
70,916 KB
testcase_32 AC 68 ms
70,912 KB
testcase_33 AC 67 ms
71,232 KB
testcase_34 AC 66 ms
71,252 KB
testcase_35 AC 67 ms
71,224 KB
testcase_36 AC 66 ms
71,132 KB
testcase_37 AC 68 ms
71,120 KB
testcase_38 AC 64 ms
71,360 KB
testcase_39 AC 67 ms
71,304 KB
testcase_40 AC 127 ms
77,188 KB
testcase_41 AC 137 ms
77,284 KB
testcase_42 AC 128 ms
77,376 KB
testcase_43 AC 122 ms
77,564 KB
testcase_44 AC 124 ms
77,468 KB
testcase_45 AC 133 ms
77,428 KB
testcase_46 AC 120 ms
77,568 KB
testcase_47 AC 128 ms
77,404 KB
testcase_48 AC 129 ms
77,772 KB
testcase_49 AC 118 ms
77,736 KB
testcase_50 AC 121 ms
77,428 KB
testcase_51 AC 131 ms
77,664 KB
testcase_52 AC 119 ms
77,556 KB
testcase_53 AC 126 ms
77,768 KB
testcase_54 AC 122 ms
77,252 KB
testcase_55 AC 127 ms
77,564 KB
testcase_56 AC 123 ms
77,788 KB
testcase_57 AC 119 ms
77,636 KB
testcase_58 AC 129 ms
77,688 KB
testcase_59 AC 125 ms
77,500 KB
testcase_60 AC 74 ms
75,612 KB
testcase_61 AC 67 ms
71,228 KB
testcase_62 AC 109 ms
76,600 KB
testcase_63 AC 77 ms
76,168 KB
testcase_64 AC 77 ms
76,200 KB
testcase_65 AC 86 ms
76,840 KB
testcase_66 AC 86 ms
76,832 KB
testcase_67 AC 88 ms
77,064 KB
testcase_68 AC 75 ms
76,004 KB
testcase_69 AC 77 ms
75,916 KB
testcase_70 AC 78 ms
76,100 KB
testcase_71 AC 65 ms
71,208 KB
testcase_72 AC 66 ms
71,112 KB
testcase_73 AC 65 ms
71,072 KB
testcase_74 AC 67 ms
71,236 KB
testcase_75 AC 67 ms
71,144 KB
testcase_76 AC 66 ms
71,344 KB
testcase_77 AC 67 ms
71,216 KB
testcase_78 AC 66 ms
71,136 KB
testcase_79 AC 83 ms
76,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
def getlist(): return list(map(int, input().split()))
        
def main():
    n,m = getlist()
    INF = 10 ** 9 + 7
    dist = [[float('inf')] * n for _ in range(n)]
    for i in range(n):
        dist[i][i] = 0
    for _ in range(m):
        s,t,d = getlist()
        dist[s-1][t-1] = min(dist[s-1][t-1],d)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j])
    for i in range(n):
        ans = 0
        for j in range(n):
            if dist[i][j] != float('inf'):
                ans += dist[i][j]
        print(ans)

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