結果

問題 No.1344 Typical Shortest Path Sum
コンテスト
ユーザー H3PO4
提出日時 2021-01-16 13:12:40
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 418 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 70 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 65,748 KB
最終ジャッジ日時 2026-09-30 21:22:29
合計ジャッジ時間 99,291 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 69 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import numpy as np

from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

N, M = map(int, input().split())
edges = np.array([tuple(map(int, input().split())) for _ in range(M)])
edges[:, :2] -= 1
matr = csr_matrix((edges[:, 2], (edges[:, 0], edges[:, 1])), shape=(N, N))
way = floyd_warshall(matr)
way = np.where(np.isinf(way), 0, way.astype(np.int64))
print(*way.sum(axis=1), sep='\n')
0