結果
問題 | No.788 トラックの移動 |
ユーザー |
![]() |
提出日時 | 2020-03-17 11:41:42 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 847 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 237,180 KB |
最終ジャッジ日時 | 2024-11-30 16:56:25 |
合計ジャッジ時間 | 29,103 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 4 |
ソースコード
#!/usr/bin/env python3.8# %%import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinesimport numpy as npfrom scipy.sparse.csgraph import dijkstrafrom scipy.sparse import csr_matrix# %%N, M, L = map(int, readline().split())T = np.array(readline().split(), np.int64)ABC = np.array(read().split(), np.int64)A = ABC[::3] - 1B = ABC[1::3] - 1C = ABC[2::3]# %%if np.count_nonzero(T > 0) <= 1:print(0)exit()# %%graph = csr_matrix((N, N))for a, b, c in zip(A, B, C):if graph[a, b] == 0 or graph[a, b] > c:graph[a, b] = cdist = dijkstra(graph, directed=False)# %%dist = (dist + .5).astype(np.int64)cost = (dist * T[None, :]).sum(axis=1) * 2diff = -dist + dist[L - 1][None, :]diff[:, T == 0] += 10 ** 12cost = cost[:, None] + diffprint(cost.min())