https://www.codechef.com/viewsolution/51197516
I used BFS on all nodes who haven’t been visited to find all connected components and their size. I see similar successful submissions to this question so why am I getting TLE?
https://www.codechef.com/viewsolution/51197516
I used BFS on all nodes who haven’t been visited to find all connected components and their size. I see similar successful submissions to this question so why am I getting TLE?
vector<vector<int> > adj
Take this by reference instead of by value, as you have done with dist
.
Thank you so much!