結果
| 問題 |
No.848 なかよし旅行
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2021-01-02 00:21:37 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 743 bytes |
| コンパイル時間 | 272 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 60,136 KB |
| 最終ジャッジ日時 | 2024-10-11 13:33:28 |
| 合計ジャッジ時間 | 6,798 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | TLE * 1 -- * 25 |
ソースコード
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N, M, P, Q, T = map(int, input().split())
A, B, C = np.array([input().split() for _ in range(M)], dtype=np.int64).T
G = csr_matrix((C, (A-1, B-1)), shape=(N, N))
path = (dijkstra(G, directed=False) + 0.01).astype(np.int64)
# ぜんぶ2人で回る
t = path[0][P-1] + path[P-1][Q-1] + path[Q-1][0]
if t <= T:
print(T)
exit()
ans = 0
same = path[0, :]
toP = path[:, P-1]
toQ = path[:, Q-1]
time = 2 * (same + np.maximum(toP, toQ))
wait = np.maximum(0, T - time)
if (time > T).all():
print(-1)
exit()
ans = (2 * same + wait)[time <= T].max()
print(ans)
tktk_snsn