79595364

Date: 2025-04-27 18:45:44
Score: 2
Natty:
Report link
  1. Reconstruct Graph as SCC (Strongly COnnected Component) only, Thus making it a DAG.

  2. Once new Graph is constructed (SCC only) calculate InDeg for every vertices.

  3. Now find number of vertices with 0 indeg other then source. This would be our ans. (Note: this by default always be minimum as the Converting Graph to SCC pops out the SCC in linear/ DAG manner and we can check how all SCCs can be connected with each other to be 1 single SCC (which is goal but with minimum edges to be added))

    Now how to convert graph to SCC? Use of Kosaraju's Algorithm (https://www.geeksforgeeks.org/kosarajus-algorithm-in-c/)

    Only difficult part here is to to see how can implement Kosaraju's algo in the code as per the requirement which can sometimes tricky.

Reasons:
  • Blacklisted phrase (0.5): how can i
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Devansh Bhatt