結果

問題 No.1344 Typical Shortest Path Sum
ユーザー convexineqconvexineq
提出日時 2021-01-16 13:41:30
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 76,420 KB
最終ジャッジ日時 2023-08-18 10:13:33
合計ジャッジ時間 9,289 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,864 KB
testcase_01 AC 74 ms
71,024 KB
testcase_02 AC 71 ms
70,996 KB
testcase_03 AC 80 ms
75,548 KB
testcase_04 AC 77 ms
75,740 KB
testcase_05 AC 73 ms
71,032 KB
testcase_06 AC 74 ms
71,020 KB
testcase_07 AC 74 ms
70,616 KB
testcase_08 AC 70 ms
71,004 KB
testcase_09 AC 71 ms
70,728 KB
testcase_10 AC 69 ms
70,952 KB
testcase_11 AC 71 ms
70,592 KB
testcase_12 AC 70 ms
71,020 KB
testcase_13 AC 69 ms
71,016 KB
testcase_14 AC 73 ms
70,732 KB
testcase_15 AC 71 ms
70,916 KB
testcase_16 AC 82 ms
76,360 KB
testcase_17 AC 73 ms
71,024 KB
testcase_18 AC 74 ms
70,956 KB
testcase_19 AC 71 ms
70,620 KB
testcase_20 AC 72 ms
70,796 KB
testcase_21 AC 72 ms
70,932 KB
testcase_22 AC 71 ms
70,996 KB
testcase_23 AC 72 ms
71,048 KB
testcase_24 AC 71 ms
70,984 KB
testcase_25 AC 71 ms
71,028 KB
testcase_26 AC 73 ms
70,972 KB
testcase_27 AC 73 ms
70,724 KB
testcase_28 AC 72 ms
71,028 KB
testcase_29 AC 73 ms
71,032 KB
testcase_30 AC 74 ms
71,000 KB
testcase_31 AC 71 ms
70,944 KB
testcase_32 AC 72 ms
70,804 KB
testcase_33 AC 71 ms
71,000 KB
testcase_34 AC 73 ms
70,696 KB
testcase_35 AC 72 ms
70,992 KB
testcase_36 AC 72 ms
71,024 KB
testcase_37 AC 72 ms
70,876 KB
testcase_38 AC 71 ms
71,032 KB
testcase_39 AC 70 ms
70,912 KB
testcase_40 AC 90 ms
76,028 KB
testcase_41 AC 103 ms
76,300 KB
testcase_42 AC 90 ms
76,076 KB
testcase_43 AC 94 ms
75,980 KB
testcase_44 AC 90 ms
75,976 KB
testcase_45 AC 92 ms
76,344 KB
testcase_46 AC 93 ms
76,328 KB
testcase_47 AC 92 ms
75,912 KB
testcase_48 AC 91 ms
75,944 KB
testcase_49 AC 92 ms
75,964 KB
testcase_50 AC 91 ms
76,088 KB
testcase_51 AC 95 ms
75,788 KB
testcase_52 AC 92 ms
75,948 KB
testcase_53 AC 91 ms
76,072 KB
testcase_54 AC 90 ms
76,072 KB
testcase_55 AC 92 ms
76,060 KB
testcase_56 AC 111 ms
76,048 KB
testcase_57 AC 104 ms
75,864 KB
testcase_58 AC 99 ms
76,080 KB
testcase_59 AC 95 ms
75,948 KB
testcase_60 AC 78 ms
75,160 KB
testcase_61 AC 73 ms
70,948 KB
testcase_62 AC 88 ms
76,420 KB
testcase_63 AC 82 ms
75,604 KB
testcase_64 AC 83 ms
75,784 KB
testcase_65 AC 87 ms
76,096 KB
testcase_66 AC 85 ms
76,408 KB
testcase_67 AC 84 ms
76,244 KB
testcase_68 AC 79 ms
75,536 KB
testcase_69 AC 81 ms
76,024 KB
testcase_70 AC 80 ms
75,548 KB
testcase_71 AC 72 ms
70,900 KB
testcase_72 AC 70 ms
71,004 KB
testcase_73 AC 72 ms
70,960 KB
testcase_74 AC 71 ms
70,944 KB
testcase_75 AC 71 ms
71,144 KB
testcase_76 AC 72 ms
70,872 KB
testcase_77 AC 72 ms
70,848 KB
testcase_78 AC 72 ms
70,948 KB
testcase_79 AC 82 ms
75,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Floyd_Warshall(dist,num_of_vertices): 
    for k in range(num_of_vertices):
        for i in range(num_of_vertices):
            for j in range(num_of_vertices):
                dist[i][j] = min(dist[i][j], dist[i][k]+ dist[k][j])

n,m,*std = map(int,open(0).read().split())
INF = 1<<60
g = [[INF]*n for _ in range(n)]
for i in range(n): g[i][i] = 0
for i in range(m):
    i *= 3
    g[std[i]-1][std[i+1]-1] = min(g[std[i]-1][std[i+1]-1], std[i+2])
Floyd_Warshall(g,n)

for i in range(n):
    ans = 0
    for j in range(n):
        if g[i][j] < INF/10: ans += g[i][j]
    print(ans)
0