結果

問題 No.1344 Typical Shortest Path Sum
ユーザー tnodinotnodino
提出日時 2022-05-06 19:19:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 78,136 KB
最終ジャッジ日時 2023-09-19 08:28:42
合計ジャッジ時間 11,542 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,220 KB
testcase_01 AC 77 ms
71,392 KB
testcase_02 AC 75 ms
71,384 KB
testcase_03 AC 86 ms
76,016 KB
testcase_04 AC 82 ms
76,136 KB
testcase_05 AC 74 ms
71,204 KB
testcase_06 AC 73 ms
71,324 KB
testcase_07 AC 76 ms
71,144 KB
testcase_08 AC 78 ms
71,224 KB
testcase_09 AC 77 ms
71,088 KB
testcase_10 AC 77 ms
71,084 KB
testcase_11 AC 76 ms
71,092 KB
testcase_12 AC 76 ms
71,260 KB
testcase_13 AC 75 ms
71,360 KB
testcase_14 AC 77 ms
71,272 KB
testcase_15 AC 76 ms
71,388 KB
testcase_16 AC 102 ms
77,276 KB
testcase_17 AC 75 ms
71,264 KB
testcase_18 AC 76 ms
71,088 KB
testcase_19 AC 76 ms
71,020 KB
testcase_20 AC 76 ms
71,020 KB
testcase_21 AC 73 ms
71,088 KB
testcase_22 AC 77 ms
71,220 KB
testcase_23 AC 76 ms
71,264 KB
testcase_24 AC 75 ms
71,140 KB
testcase_25 AC 73 ms
71,384 KB
testcase_26 AC 77 ms
71,332 KB
testcase_27 AC 78 ms
71,460 KB
testcase_28 AC 76 ms
71,212 KB
testcase_29 AC 75 ms
71,280 KB
testcase_30 AC 75 ms
71,256 KB
testcase_31 AC 73 ms
71,384 KB
testcase_32 AC 76 ms
71,484 KB
testcase_33 AC 75 ms
71,088 KB
testcase_34 AC 76 ms
71,464 KB
testcase_35 AC 75 ms
71,020 KB
testcase_36 AC 75 ms
71,372 KB
testcase_37 AC 74 ms
71,460 KB
testcase_38 AC 78 ms
71,088 KB
testcase_39 AC 76 ms
71,312 KB
testcase_40 AC 139 ms
77,912 KB
testcase_41 AC 158 ms
77,708 KB
testcase_42 AC 139 ms
77,576 KB
testcase_43 AC 141 ms
77,896 KB
testcase_44 AC 144 ms
77,868 KB
testcase_45 AC 146 ms
77,804 KB
testcase_46 AC 144 ms
77,392 KB
testcase_47 AC 142 ms
77,876 KB
testcase_48 AC 153 ms
78,060 KB
testcase_49 AC 140 ms
77,692 KB
testcase_50 AC 143 ms
77,556 KB
testcase_51 AC 146 ms
77,564 KB
testcase_52 AC 137 ms
77,592 KB
testcase_53 AC 162 ms
77,872 KB
testcase_54 AC 138 ms
77,868 KB
testcase_55 AC 146 ms
77,676 KB
testcase_56 AC 156 ms
78,136 KB
testcase_57 AC 142 ms
77,712 KB
testcase_58 AC 153 ms
77,680 KB
testcase_59 AC 190 ms
77,884 KB
testcase_60 AC 85 ms
75,476 KB
testcase_61 AC 78 ms
71,288 KB
testcase_62 AC 112 ms
77,004 KB
testcase_63 AC 89 ms
76,156 KB
testcase_64 AC 93 ms
76,064 KB
testcase_65 AC 112 ms
76,900 KB
testcase_66 AC 112 ms
76,744 KB
testcase_67 AC 115 ms
77,132 KB
testcase_68 AC 90 ms
76,036 KB
testcase_69 AC 92 ms
75,796 KB
testcase_70 AC 91 ms
75,580 KB
testcase_71 AC 80 ms
71,408 KB
testcase_72 AC 80 ms
71,088 KB
testcase_73 AC 79 ms
71,208 KB
testcase_74 AC 78 ms
71,208 KB
testcase_75 AC 77 ms
71,308 KB
testcase_76 AC 79 ms
71,484 KB
testcase_77 AC 81 ms
71,392 KB
testcase_78 AC 80 ms
71,252 KB
testcase_79 AC 97 ms
76,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def WarshallFloyd(N, Cost):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if Cost[i][k] + Cost[k][j] < Cost[i][j]:
                    Cost[i][j] = Cost[i][k] + Cost[k][j]
    return Cost

INF = 1<<64
N,M = map(int,input().split())
Cost = [[INF] * N for _ in range(N)]
for i in range(N):
    Cost[i][i] = 0
for _ in range(M):
    s,t,d = map(int,input().split())
    s -= 1
    t -= 1
    Cost[s][t] = min(Cost[s][t], d)
Cost = WarshallFloyd(N, Cost)
for i in range(N):
    ans = 0
    for j in range(N):
        if Cost[i][j] <= INF // 2:
            ans += Cost[i][j]
    print(ans)
0