結果

問題 No.807 umg tours
ユーザー H3PO4H3PO4
提出日時 2021-02-10 10:40:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,788 ms / 4,000 ms
コード長 793 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 173,656 KB
最終ジャッジ日時 2023-09-22 03:54:22
合計ジャッジ時間 28,264 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 217 ms
43,420 KB
testcase_01 AC 216 ms
43,308 KB
testcase_02 AC 219 ms
43,752 KB
testcase_03 AC 221 ms
43,580 KB
testcase_04 AC 213 ms
43,676 KB
testcase_05 AC 216 ms
43,428 KB
testcase_06 AC 217 ms
43,560 KB
testcase_07 AC 214 ms
43,620 KB
testcase_08 AC 213 ms
43,220 KB
testcase_09 AC 217 ms
43,472 KB
testcase_10 AC 217 ms
43,284 KB
testcase_11 AC 1,320 ms
145,240 KB
testcase_12 AC 1,085 ms
115,636 KB
testcase_13 AC 1,442 ms
150,284 KB
testcase_14 AC 717 ms
88,268 KB
testcase_15 AC 639 ms
80,084 KB
testcase_16 AC 1,534 ms
160,812 KB
testcase_17 AC 1,782 ms
172,524 KB
testcase_18 AC 1,788 ms
172,884 KB
testcase_19 AC 1,788 ms
171,744 KB
testcase_20 AC 1,061 ms
108,356 KB
testcase_21 AC 1,117 ms
110,780 KB
testcase_22 AC 569 ms
72,068 KB
testcase_23 AC 493 ms
65,884 KB
testcase_24 AC 1,349 ms
143,928 KB
testcase_25 AC 1,757 ms
173,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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')
0