結果
問題 | No.807 umg tours |
ユーザー |
|
提出日時 | 2021-02-10 10:40:23 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 2,796 ms / 4,000 ms |
コード長 | 793 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 185,376 KB |
最終ジャッジ日時 | 2024-07-07 20:40:16 |
合計ジャッジ時間 | 46,636 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
外部呼び出し有り |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
import sys from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix input = sys.stdin.buffer.readline N, M = map(int, input().split()) frm, to, length = [0] * (6 * M), [0] * (6 * M), [0] * (6 * M) for i in range(0, 6 * M, 6): a, b, c = map(int, input().split()) a -= 1 b -= 1 frm[i], to[i], length[i] = a, b, c frm[i + 1], to[i + 1], length[i + 1] = b, a, c frm[i + 2], to[i + 2], length[i + 2] = a + N, b + N, c frm[i + 3], to[i + 3], length[i + 3] = b + N, a + N, c frm[i + 4], to[i + 4], length[i + 4] = a, b + N, 0 frm[i + 5], to[i + 5], length[i + 5] = b, a + N, 0 matr = csr_matrix((length, (frm, to)), shape=(2 * N, 2 * N)) way = dijkstra(matr, indices=0).astype(int) ans = way[:N] + way[N:] ans[0] = 0 print(*ans, sep='\n')