1865. Checking Existence of Edge Length Limited Paths II

Hard
Depth-First Search
Union-Find
Graph Theory
Design
Sorting
Heap (Priority Queue)
Minimum Spanning Tree

Description

Hints

Hint 1
Find the minimum spanning tree of the given graph.
Hint 2
Root the tree in an arbitrary node and calculate the maximum weight of the edge from each node to the chosen root.
Hint 3
To answer a query, find the lca between the two nodes, and find the maximum weight from each of the query nodes to their lca and compare it to the given limit.

Statistics

Acceptance
51.8%
Submissions
7,958
Accepted
4,123