← 返回 uber 的题目列表Offline Union-Find for edge-length-limited connectivity queries
类型:online_judge
Problem (inferred from the post; may be incomplete)
You are given a weighted undirected graph with n nodes labeled 0..n-1, an edge list edges, and a list of queries queries. Each query is (p, q, limit):
p, q: two nodes
limit: an edge-weight threshold
For each query, determine whether there exists a path from p to q such that every edge weight on the path is strictly less than limit.
Input
n
edges: [[u, v, w], ...]
queries: [[p, q, limit], ...]
Output
Return a boolean array of length len(queries).
Constraints (not provided in the post; typical values for this problem)
1 <= n <= 1e5
0 <= |edges|, |queries| <= 2e5
Example
Input:
n = 3
edges = [[0,1,2],[1,2,4],[0,2,8]]
queries = [[0,2,5],[0,2,9]]
Output:
[true, true]
Example
Input
3
3
0 1 2
1 2 4
0 2 8
2
0 2 5
0 2 9
Output
true true