結果

問題 No.1344 Typical Shortest Path Sum
ユーザー ああいいああいい
提出日時 2022-01-29 16:59:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 559 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 77,900 KB
最終ジャッジ日時 2023-08-30 16:46:56
合計ジャッジ時間 9,127 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,496 KB
testcase_01 AC 69 ms
71,420 KB
testcase_02 AC 67 ms
71,388 KB
testcase_03 AC 74 ms
76,196 KB
testcase_04 AC 74 ms
76,396 KB
testcase_05 AC 67 ms
71,136 KB
testcase_06 AC 68 ms
71,084 KB
testcase_07 AC 66 ms
71,252 KB
testcase_08 AC 66 ms
71,324 KB
testcase_09 AC 67 ms
71,532 KB
testcase_10 AC 67 ms
71,212 KB
testcase_11 AC 66 ms
71,392 KB
testcase_12 AC 66 ms
71,376 KB
testcase_13 AC 69 ms
71,492 KB
testcase_14 AC 68 ms
71,332 KB
testcase_15 AC 65 ms
71,432 KB
testcase_16 AC 75 ms
76,504 KB
testcase_17 AC 65 ms
71,392 KB
testcase_18 AC 68 ms
71,492 KB
testcase_19 AC 68 ms
71,380 KB
testcase_20 AC 67 ms
71,344 KB
testcase_21 AC 68 ms
71,428 KB
testcase_22 AC 70 ms
71,216 KB
testcase_23 AC 65 ms
71,276 KB
testcase_24 AC 66 ms
71,240 KB
testcase_25 AC 65 ms
71,320 KB
testcase_26 AC 67 ms
71,372 KB
testcase_27 AC 66 ms
71,376 KB
testcase_28 AC 67 ms
71,136 KB
testcase_29 AC 70 ms
71,576 KB
testcase_30 AC 69 ms
71,104 KB
testcase_31 AC 66 ms
71,292 KB
testcase_32 AC 65 ms
71,456 KB
testcase_33 AC 65 ms
71,596 KB
testcase_34 AC 65 ms
71,284 KB
testcase_35 AC 66 ms
71,508 KB
testcase_36 AC 69 ms
71,596 KB
testcase_37 AC 72 ms
71,244 KB
testcase_38 AC 70 ms
71,188 KB
testcase_39 AC 67 ms
71,484 KB
testcase_40 AC 86 ms
76,480 KB
testcase_41 AC 86 ms
76,628 KB
testcase_42 AC 85 ms
76,400 KB
testcase_43 AC 83 ms
76,280 KB
testcase_44 AC 82 ms
76,472 KB
testcase_45 AC 87 ms
76,528 KB
testcase_46 AC 85 ms
76,620 KB
testcase_47 AC 82 ms
76,692 KB
testcase_48 AC 87 ms
76,492 KB
testcase_49 AC 81 ms
76,536 KB
testcase_50 AC 83 ms
76,476 KB
testcase_51 AC 90 ms
76,456 KB
testcase_52 AC 86 ms
76,204 KB
testcase_53 AC 92 ms
76,464 KB
testcase_54 AC 84 ms
76,616 KB
testcase_55 AC 86 ms
76,412 KB
testcase_56 AC 86 ms
76,344 KB
testcase_57 AC 83 ms
76,444 KB
testcase_58 AC 87 ms
76,448 KB
testcase_59 AC 83 ms
76,432 KB
testcase_60 AC 72 ms
76,080 KB
testcase_61 AC 67 ms
71,276 KB
testcase_62 AC 104 ms
77,824 KB
testcase_63 AC 84 ms
76,096 KB
testcase_64 AC 84 ms
76,444 KB
testcase_65 AC 102 ms
77,752 KB
testcase_66 AC 106 ms
77,900 KB
testcase_67 AC 103 ms
77,740 KB
testcase_68 AC 80 ms
76,308 KB
testcase_69 AC 80 ms
76,532 KB
testcase_70 AC 75 ms
76,056 KB
testcase_71 AC 66 ms
71,080 KB
testcase_72 AC 67 ms
71,340 KB
testcase_73 AC 66 ms
71,376 KB
testcase_74 AC 66 ms
71,352 KB
testcase_75 AC 65 ms
71,088 KB
testcase_76 AC 66 ms
71,300 KB
testcase_77 AC 66 ms
71,576 KB
testcase_78 AC 68 ms
71,384 KB
testcase_79 AC 77 ms
76,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
inf = 10 ** 18
dist = [[inf] * N for _ in range(N)]
for _ in range(M):
    s,t,d = map(int,input().split())
    dist[s-1][t-1] = min(dist[s-1][t-1],d)
for i in range(N):
    dist[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            if dist[i][k] == inf or dist[k][j] == inf:continue
            dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j])
for i in range(N):
    for j in range(N):
        if dist[i][j] == inf:
            dist[i][j] = 0
for i in range(N):
    print(sum(dist[i]))
0