Problem · Graph
Drop-Off Centers
Learn this problemProblem statement
Each graph node is a potential drop-off center owned by one company. A contracted company contributes all of its centers. Count non-empty company subsets for which every pair of selected centers is at least minDistance apart by shortest-road distance.
Function
findCount(n: int, graphFrom: int[], graphTo: int[], graphWeight: int[], minDistance: int, company: int[]) → intExamples
Example 1
n = 3graphFrom = [1,2,3]graphTo = [2,3,1]graphWeight = [3,2,5]minDistance = 4company = [1,2,3]return = 4The valid subsets are each singleton and companies 1 with 3.
Constraints
2 <= n <= 10001 <= edges <= n(n-1)/21 <= edge weight, minDistance <= 1001 <= companies <= 10- There is at most one road between a node pair.