結果
問題 | No.788 トラックの移動 |
ユーザー | H3PO4 |
提出日時 | 2021-02-04 09:49:04 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 838 bytes |
コンパイル時間 | 670 ms |
コンパイル使用メモリ | 10,948 KB |
実行使用メモリ | 105,952 KB |
最終ジャッジ日時 | 2023-09-13 04:47:26 |
合計ジャッジ時間 | 12,890 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,600 ms
105,952 KB |
testcase_01 | AC | 199 ms
43,236 KB |
testcase_02 | AC | 195 ms
43,452 KB |
testcase_03 | AC | 193 ms
43,324 KB |
testcase_04 | AC | 509 ms
58,496 KB |
testcase_05 | AC | 1,528 ms
105,712 KB |
testcase_06 | AC | 1,599 ms
105,776 KB |
testcase_07 | AC | 194 ms
43,484 KB |
testcase_08 | AC | 193 ms
43,508 KB |
testcase_09 | AC | 195 ms
43,240 KB |
testcase_10 | AC | 194 ms
43,360 KB |
testcase_11 | AC | 192 ms
43,468 KB |
testcase_12 | AC | 192 ms
43,516 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 469 ms
105,852 KB |
testcase_16 | AC | 1,090 ms
105,808 KB |
ソースコード
from collections import defaultdict import numpy as np from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix N, M, L = map(int, input().split()) L -= 1 # 0-indexed T = np.array(list(map(int, input().split())), dtype=np.int64) nonzero = np.nonzero(T)[0] d = defaultdict(lambda: 2 * 10 ** 6) for _ in range(M): a, b, c = map(int, input().split()) a -= 1 b -= 1 d[(a, b)] = min(d[(a, b)], c) frm, to, length = [], [], [] for (a, b), c in d.items(): frm.append(a) to.append(b) length.append(c) matr = csr_matrix((length, (frm, to)), shape=(N, N)) way = dijkstra(matr, directed=False).astype(np.int64) ans = np.inf for target in range(N): tmp = np.sum(way[target] * 2 * T) first = np.max(way[target][nonzero] - way[L][nonzero]) tmp -= first ans = min(ans, tmp) print(ans)