結果
| 問題 | No.1344 Typical Shortest Path Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-16 13:17:29 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 656 bytes |
| 記録 | |
| コンパイル時間 | 351 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 119,140 KB |
| 最終ジャッジ日時 | 2026-05-10 11:11:40 |
| 合計ジャッジ時間 | 128,352 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | AC * 77 |
ソースコード
from collections import defaultdict
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
N, M = map(int, input().split())
length, frm, to = [], [], []
MAX = 10 ** 13
edges_dict = defaultdict(lambda: MAX)
for _ in range(M):
s, t, d = map(int, input().split())
s -= 1
t -= 1
edges_dict[(s, t)] = min(edges_dict[(s, t)], d)
for (s, t), d in edges_dict.items():
length.append(d)
frm.append(s)
to.append(t)
matr = csr_matrix((length, (frm, to)), 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')