結果

問題 No.1344 Typical Shortest Path Sum
ユーザー tnodinotnodino
提出日時 2022-05-06 19:14:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 619 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 78,232 KB
最終ジャッジ日時 2023-09-19 08:25:33
合計ジャッジ時間 11,347 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,172 KB
testcase_01 AC 82 ms
71,308 KB
testcase_02 AC 78 ms
71,276 KB
testcase_03 AC 91 ms
76,360 KB
testcase_04 AC 91 ms
76,096 KB
testcase_05 AC 80 ms
71,244 KB
testcase_06 AC 80 ms
71,276 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 79 ms
71,348 KB
testcase_10 AC 81 ms
71,272 KB
testcase_11 AC 80 ms
71,176 KB
testcase_12 WA -
testcase_13 AC 80 ms
71,056 KB
testcase_14 AC 80 ms
71,272 KB
testcase_15 AC 78 ms
71,064 KB
testcase_16 AC 104 ms
77,424 KB
testcase_17 AC 78 ms
71,256 KB
testcase_18 AC 82 ms
71,352 KB
testcase_19 AC 80 ms
71,212 KB
testcase_20 AC 80 ms
71,496 KB
testcase_21 AC 79 ms
71,440 KB
testcase_22 AC 80 ms
71,488 KB
testcase_23 AC 80 ms
71,528 KB
testcase_24 AC 80 ms
71,348 KB
testcase_25 AC 77 ms
71,356 KB
testcase_26 AC 80 ms
71,176 KB
testcase_27 AC 79 ms
71,256 KB
testcase_28 AC 80 ms
71,060 KB
testcase_29 AC 79 ms
71,376 KB
testcase_30 AC 81 ms
71,280 KB
testcase_31 AC 79 ms
71,380 KB
testcase_32 AC 82 ms
71,184 KB
testcase_33 AC 80 ms
71,472 KB
testcase_34 AC 81 ms
71,064 KB
testcase_35 AC 81 ms
71,264 KB
testcase_36 AC 80 ms
71,204 KB
testcase_37 AC 80 ms
71,184 KB
testcase_38 AC 79 ms
71,508 KB
testcase_39 AC 79 ms
71,292 KB
testcase_40 AC 147 ms
77,640 KB
testcase_41 AC 163 ms
77,960 KB
testcase_42 AC 160 ms
77,448 KB
testcase_43 AC 147 ms
77,884 KB
testcase_44 AC 145 ms
77,776 KB
testcase_45 AC 153 ms
78,000 KB
testcase_46 AC 148 ms
77,796 KB
testcase_47 AC 147 ms
77,944 KB
testcase_48 AC 156 ms
78,008 KB
testcase_49 AC 142 ms
77,836 KB
testcase_50 AC 143 ms
77,576 KB
testcase_51 AC 146 ms
77,784 KB
testcase_52 AC 140 ms
77,928 KB
testcase_53 AC 161 ms
77,916 KB
testcase_54 AC 140 ms
77,920 KB
testcase_55 AC 147 ms
77,884 KB
testcase_56 AC 155 ms
78,232 KB
testcase_57 AC 144 ms
78,108 KB
testcase_58 AC 156 ms
77,780 KB
testcase_59 AC 153 ms
77,884 KB
testcase_60 AC 88 ms
75,708 KB
testcase_61 AC 80 ms
71,568 KB
testcase_62 AC 114 ms
77,232 KB
testcase_63 AC 93 ms
76,136 KB
testcase_64 AC 95 ms
75,968 KB
testcase_65 AC 115 ms
76,892 KB
testcase_66 AC 116 ms
76,752 KB
testcase_67 AC 114 ms
77,068 KB
testcase_68 AC 91 ms
76,148 KB
testcase_69 AC 91 ms
76,148 KB
testcase_70 AC 94 ms
75,760 KB
testcase_71 AC 78 ms
71,148 KB
testcase_72 AC 80 ms
71,384 KB
testcase_73 AC 80 ms
71,316 KB
testcase_74 AC 80 ms
71,404 KB
testcase_75 AC 79 ms
71,392 KB
testcase_76 AC 80 ms
71,184 KB
testcase_77 AC 82 ms
71,392 KB
testcase_78 AC 81 ms
71,260 KB
testcase_79 AC 97 ms
76,260 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<<100
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] = 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