You are working on Uber's driver network analysis system, which models drivers as nodes in a graph. A connection (edge) exists between two drivers if they frequently operate in the same area or share rides in pooled trips. Uber wants to analyze these connected groups of drivers (connected components) to optimize demand prediction and driver incentives.
Definitions
A connected group of drivers is a connected component.
The order of a component = number of drivers in it.
The support value of a component = ceil(sqrt(component_size))
Goal
Return the total support value across all connected components.
Function Signature int totalSupport( int drivers_nodes, vector<int> drivers_from, vector<int> drivers_to );
Example Explanation
If components are:
(1,2,3,4,5) → size = 5 → ceil(√5) = 3
(7,8) → size = 2 → ceil(√2) = 2
Three isolated nodes → each size = 1 → ceil(√1) = 1
Total = 3 + 2 + 1 + 1 + 1 = 8
2 ≤ drivers_nodes ≤ 10^5
1 ≤ drivers_edges ≤ 10^5
1 ≤ drivers_from[i], drivers_to[i] ≤ drivers_nodes
Hard