problem : You are given a directed graph with n veritces and m edges and a source vertex s.Find the mimimum number of edges to be added, so that all the vertices are reachable from the source. The added edges are also directed.

my apporach: I first calculate the number of vertices whose indegree is zero, store it in ans, then increase the ans by the number of unvisited components which don’t have even a single vertex with indegree equal to zero.

It would be great help if i get to know why my approach is wrong. Thanks.

problem : Reachability from capital

my soluion : https://codeforces.com/contest/999/submission/62055801