結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,264 KB
testcase_01 AC 77 ms
71,080 KB
testcase_02 AC 78 ms
71,060 KB
testcase_03 AC 94 ms
76,032 KB
testcase_04 AC 89 ms
76,180 KB
testcase_05 AC 77 ms
71,288 KB
testcase_06 AC 75 ms
71,536 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 78 ms
71,176 KB
testcase_10 AC 75 ms
71,264 KB
testcase_11 AC 74 ms
71,284 KB
testcase_12 WA -
testcase_13 AC 78 ms
71,096 KB
testcase_14 AC 76 ms
71,264 KB
testcase_15 AC 75 ms
71,196 KB
testcase_16 AC 104 ms
77,224 KB
testcase_17 AC 78 ms
71,504 KB
testcase_18 AC 79 ms
71,284 KB
testcase_19 AC 77 ms
71,384 KB
testcase_20 AC 75 ms
71,172 KB
testcase_21 AC 73 ms
71,392 KB
testcase_22 AC 75 ms
71,472 KB
testcase_23 AC 80 ms
71,256 KB
testcase_24 AC 78 ms
71,056 KB
testcase_25 AC 77 ms
71,184 KB
testcase_26 AC 76 ms
71,100 KB
testcase_27 AC 78 ms
71,236 KB
testcase_28 AC 77 ms
71,500 KB
testcase_29 AC 76 ms
71,080 KB
testcase_30 AC 78 ms
71,256 KB
testcase_31 AC 76 ms
71,212 KB
testcase_32 AC 77 ms
71,280 KB
testcase_33 AC 77 ms
71,216 KB
testcase_34 AC 78 ms
71,500 KB
testcase_35 AC 77 ms
71,408 KB
testcase_36 AC 77 ms
71,268 KB
testcase_37 AC 77 ms
71,200 KB
testcase_38 AC 79 ms
71,512 KB
testcase_39 AC 79 ms
71,432 KB
testcase_40 AC 143 ms
77,716 KB
testcase_41 AC 165 ms
77,976 KB
testcase_42 AC 141 ms
77,840 KB
testcase_43 AC 142 ms
77,904 KB
testcase_44 AC 145 ms
78,072 KB
testcase_45 AC 144 ms
77,748 KB
testcase_46 AC 147 ms
77,736 KB
testcase_47 AC 146 ms
77,836 KB
testcase_48 AC 151 ms
77,952 KB
testcase_49 AC 139 ms
77,844 KB
testcase_50 AC 141 ms
77,788 KB
testcase_51 AC 142 ms
77,724 KB
testcase_52 AC 137 ms
77,744 KB
testcase_53 AC 166 ms
77,944 KB
testcase_54 AC 147 ms
77,744 KB
testcase_55 AC 145 ms
77,736 KB
testcase_56 AC 153 ms
78,004 KB
testcase_57 AC 147 ms
78,168 KB
testcase_58 AC 150 ms
77,636 KB
testcase_59 AC 149 ms
77,868 KB
testcase_60 AC 87 ms
75,712 KB
testcase_61 AC 77 ms
71,240 KB
testcase_62 AC 108 ms
76,836 KB
testcase_63 AC 90 ms
76,192 KB
testcase_64 AC 90 ms
75,956 KB
testcase_65 AC 107 ms
76,708 KB
testcase_66 AC 108 ms
77,124 KB
testcase_67 AC 109 ms
76,724 KB
testcase_68 AC 90 ms
76,024 KB
testcase_69 AC 88 ms
76,088 KB
testcase_70 AC 93 ms
75,872 KB
testcase_71 AC 76 ms
71,236 KB
testcase_72 AC 75 ms
71,184 KB
testcase_73 AC 76 ms
71,084 KB
testcase_74 AC 77 ms
71,168 KB
testcase_75 AC 75 ms
71,316 KB
testcase_76 AC 76 ms
71,060 KB
testcase_77 AC 78 ms
71,188 KB
testcase_78 AC 76 ms
71,184 KB
testcase_79 AC 95 ms
76,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# warshall_floyd法
def warshall_floyd() -> list:
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    return dist

INF = 10 ** 20
n, m = map(int,input().split()) # 頂点数・辺の数

dist = [[INF] * n for _ in range(n)] # 隣接行列の初期化

# 自分自身へのコストは 0
for i in range(n):
    dist[i][i] = 0

# 与えられた距離の初期化
for i in range(m):
    x, y, r = map(int,input().split())
    dist[x - 1][y - 1] = r

ans = warshall_floyd()

for i in range(n):
    num = 0
    for j in ans[i]:
        if j <= 10 ** 18:
            num += j
    print(num)
0