Uber plans to expand Green Zones (EV-only zones).
You are given:
road_nodes — number of zones
road_from[i], road_to[i] — bidirectional roads
road_weight[i] — travel distance
partner[i] — partner managing zone i
minGap — minimum shortest-path distance required between any two active Green Zones
If Uber selects a partner, all zones managed by that partner become Green Zones.
Constraint:
No two active Green Zones may be within minGap distance (shortest path distance).
Return the number of valid partner combinations.
int countGreenZonePlans( int road_nodes, int[] road_from, int[] road_to, int[] road_weight, int minGap, int[] partner )
Example 1
road_nodes = 3 road_from = [1,2,3] road_to = [2,3,1] road_weight = [3,2,5] minGap = 4 partner = [1,2,3]
Output: 4
Valid plans: {1} {2} {3} {1,3}
Example 2
Input: road_nodes = 2 road_from = [1] road_to = [2] road_weight = [5] minGap = 4 partner = [1,2]
Output: 3
Valid subsets: {} {1} {2} {1,2}
(Note: exclude empty set if required by interpretation)
1 ≤ road_nodes ≤ 1000
1 ≤ road_weight[i] ≤ 1000
1 ≤ minGap ≤ 1000
1 ≤ partner[i] ≤ 10
No self-loops
At most one edge between any two nodes