結果

問題 No.1344 Typical Shortest Path Sum
ユーザー chineristACchineristAC
提出日時 2021-01-16 13:10:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 77,888 KB
最終ジャッジ日時 2023-08-18 09:17:44
合計ジャッジ時間 10,588 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,052 KB
testcase_01 AC 72 ms
71,292 KB
testcase_02 AC 73 ms
71,380 KB
testcase_03 AC 96 ms
76,544 KB
testcase_04 AC 85 ms
76,452 KB
testcase_05 AC 74 ms
71,436 KB
testcase_06 AC 75 ms
71,380 KB
testcase_07 AC 73 ms
71,260 KB
testcase_08 AC 74 ms
71,384 KB
testcase_09 AC 76 ms
71,380 KB
testcase_10 AC 73 ms
71,272 KB
testcase_11 AC 73 ms
71,124 KB
testcase_12 AC 74 ms
71,208 KB
testcase_13 AC 72 ms
71,284 KB
testcase_14 AC 73 ms
71,440 KB
testcase_15 AC 72 ms
71,140 KB
testcase_16 AC 115 ms
77,532 KB
testcase_17 AC 74 ms
71,168 KB
testcase_18 AC 72 ms
71,196 KB
testcase_19 AC 74 ms
70,952 KB
testcase_20 AC 73 ms
71,192 KB
testcase_21 AC 72 ms
71,048 KB
testcase_22 AC 73 ms
71,304 KB
testcase_23 AC 74 ms
71,324 KB
testcase_24 AC 74 ms
71,092 KB
testcase_25 AC 74 ms
71,236 KB
testcase_26 AC 73 ms
71,172 KB
testcase_27 AC 73 ms
71,088 KB
testcase_28 AC 73 ms
71,320 KB
testcase_29 AC 72 ms
71,292 KB
testcase_30 AC 74 ms
71,228 KB
testcase_31 AC 74 ms
71,448 KB
testcase_32 AC 74 ms
71,380 KB
testcase_33 AC 73 ms
71,188 KB
testcase_34 AC 73 ms
71,228 KB
testcase_35 AC 73 ms
71,088 KB
testcase_36 AC 73 ms
71,344 KB
testcase_37 AC 73 ms
71,340 KB
testcase_38 AC 75 ms
71,256 KB
testcase_39 AC 75 ms
71,272 KB
testcase_40 AC 135 ms
77,680 KB
testcase_41 AC 141 ms
77,780 KB
testcase_42 AC 137 ms
77,424 KB
testcase_43 AC 132 ms
77,552 KB
testcase_44 AC 136 ms
77,724 KB
testcase_45 AC 138 ms
77,704 KB
testcase_46 AC 137 ms
77,884 KB
testcase_47 AC 134 ms
77,560 KB
testcase_48 AC 140 ms
77,800 KB
testcase_49 AC 129 ms
77,608 KB
testcase_50 AC 133 ms
77,580 KB
testcase_51 AC 140 ms
77,888 KB
testcase_52 AC 134 ms
77,700 KB
testcase_53 AC 146 ms
77,868 KB
testcase_54 AC 131 ms
77,608 KB
testcase_55 AC 139 ms
77,632 KB
testcase_56 AC 138 ms
77,412 KB
testcase_57 AC 135 ms
77,644 KB
testcase_58 AC 138 ms
77,656 KB
testcase_59 AC 136 ms
77,620 KB
testcase_60 AC 81 ms
75,944 KB
testcase_61 AC 74 ms
71,376 KB
testcase_62 AC 98 ms
76,888 KB
testcase_63 AC 84 ms
76,356 KB
testcase_64 AC 84 ms
76,420 KB
testcase_65 AC 97 ms
76,848 KB
testcase_66 AC 97 ms
76,800 KB
testcase_67 AC 95 ms
76,660 KB
testcase_68 AC 82 ms
76,280 KB
testcase_69 AC 82 ms
76,280 KB
testcase_70 AC 86 ms
76,088 KB
testcase_71 AC 73 ms
71,160 KB
testcase_72 AC 71 ms
71,384 KB
testcase_73 AC 74 ms
71,404 KB
testcase_74 AC 73 ms
71,324 KB
testcase_75 AC 73 ms
71,152 KB
testcase_76 AC 74 ms
70,948 KB
testcase_77 AC 72 ms
71,160 KB
testcase_78 AC 75 ms
71,092 KB
testcase_79 AC 93 ms
76,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline

N,M = map(int,input().split())
d = [[float("inf") for j in range(N)] for i in range(N)]
for i in range(M):
    s,t,w = map(int,input().split())
    d[s-1][t-1] = min(w,d[s-1][t-1])

for i in range(N):
    d[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

for i in range(N):
    res = 0
    for j in range(N):
        if d[i][j]!=float("inf"):
            res += d[i][j]
    print(res)
0