You have n junctions and m one-way roads. Each junction has a cost to build a police checkpoint. You want to build checkpoints so every junction is reachable from at least one checkpoint. Find the minimum total cost and the number of ways to achieve it.
This is an SCC problem. Within an SCC, one checkpoint covers all nodes because they can all reach each other. You need to find all SCCs, then pick the cheapest node in each SCC. Count the number of minimum-cost nodes in each SCC for the ways calculation.