結果

問題 No.1344 Typical Shortest Path Sum
ユーザー roarisroaris
提出日時 2021-01-24 05:56:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 76,820 KB
最終ジャッジ日時 2023-08-30 17:02:04
合計ジャッジ時間 8,767 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,160 KB
testcase_01 AC 67 ms
71,260 KB
testcase_02 AC 67 ms
71,144 KB
testcase_03 AC 73 ms
75,916 KB
testcase_04 AC 71 ms
75,480 KB
testcase_05 AC 67 ms
70,968 KB
testcase_06 AC 66 ms
71,172 KB
testcase_07 AC 67 ms
71,072 KB
testcase_08 AC 67 ms
71,012 KB
testcase_09 AC 68 ms
70,968 KB
testcase_10 AC 67 ms
71,172 KB
testcase_11 AC 66 ms
70,924 KB
testcase_12 AC 66 ms
70,996 KB
testcase_13 AC 67 ms
70,964 KB
testcase_14 AC 68 ms
71,260 KB
testcase_15 AC 66 ms
70,980 KB
testcase_16 AC 76 ms
76,000 KB
testcase_17 AC 65 ms
71,192 KB
testcase_18 AC 67 ms
71,268 KB
testcase_19 AC 68 ms
70,980 KB
testcase_20 AC 65 ms
70,816 KB
testcase_21 AC 66 ms
70,988 KB
testcase_22 AC 66 ms
71,104 KB
testcase_23 AC 67 ms
70,968 KB
testcase_24 AC 66 ms
71,152 KB
testcase_25 AC 65 ms
70,808 KB
testcase_26 AC 65 ms
70,964 KB
testcase_27 AC 67 ms
70,816 KB
testcase_28 AC 67 ms
71,188 KB
testcase_29 AC 66 ms
71,112 KB
testcase_30 AC 66 ms
71,264 KB
testcase_31 AC 67 ms
71,224 KB
testcase_32 AC 70 ms
71,228 KB
testcase_33 AC 72 ms
70,932 KB
testcase_34 AC 71 ms
71,224 KB
testcase_35 AC 71 ms
71,040 KB
testcase_36 AC 70 ms
71,104 KB
testcase_37 AC 72 ms
71,108 KB
testcase_38 AC 72 ms
71,188 KB
testcase_39 AC 72 ms
71,228 KB
testcase_40 AC 89 ms
75,808 KB
testcase_41 AC 84 ms
76,064 KB
testcase_42 AC 82 ms
76,124 KB
testcase_43 AC 81 ms
76,136 KB
testcase_44 AC 82 ms
76,036 KB
testcase_45 AC 83 ms
76,148 KB
testcase_46 AC 83 ms
75,976 KB
testcase_47 AC 82 ms
76,148 KB
testcase_48 AC 85 ms
76,256 KB
testcase_49 AC 80 ms
75,996 KB
testcase_50 AC 81 ms
75,996 KB
testcase_51 AC 81 ms
75,892 KB
testcase_52 AC 81 ms
75,876 KB
testcase_53 AC 88 ms
75,788 KB
testcase_54 AC 81 ms
76,272 KB
testcase_55 AC 83 ms
76,224 KB
testcase_56 AC 83 ms
76,128 KB
testcase_57 AC 81 ms
76,016 KB
testcase_58 AC 82 ms
76,088 KB
testcase_59 AC 83 ms
76,112 KB
testcase_60 AC 77 ms
75,300 KB
testcase_61 AC 71 ms
71,192 KB
testcase_62 AC 108 ms
76,660 KB
testcase_63 AC 85 ms
75,864 KB
testcase_64 AC 87 ms
75,788 KB
testcase_65 AC 108 ms
76,796 KB
testcase_66 AC 108 ms
76,588 KB
testcase_67 AC 108 ms
76,820 KB
testcase_68 AC 80 ms
75,572 KB
testcase_69 AC 78 ms
75,924 KB
testcase_70 AC 73 ms
75,456 KB
testcase_71 AC 66 ms
71,292 KB
testcase_72 AC 67 ms
71,312 KB
testcase_73 AC 67 ms
71,228 KB
testcase_74 AC 67 ms
71,188 KB
testcase_75 AC 67 ms
71,104 KB
testcase_76 AC 67 ms
71,152 KB
testcase_77 AC 67 ms
70,924 KB
testcase_78 AC 67 ms
71,168 KB
testcase_79 AC 75 ms
76,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def warshall_floyd():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if D[i][k]!=10**18 and D[k][j]!=10**18:
                    D[i][j] = min(D[i][j], D[i][k]+D[k][j])

N, M = map(int, input().split())
D = [[10**18]*N for _ in range(N)]

for i in range(N):
    D[i][i] = 0
    
for _ in range(M):
    s, t, d = map(int, input().split())
    D[s-1][t-1] = min(D[s-1][t-1], d)

warshall_floyd()

for i in range(N):
    ans = 0
    
    for j in range(N):
        if D[i][j]!=10**18:
            ans += D[i][j]
    
    print(ans)
0