Hello, Can anyone help me with this problem? After some days of thinking i notice that if we have popular cow A answer will be just all cows which A thinks is popular.But i have no idea how to find cow which is popular by every other.Can anyone help me?
Thank you.
P.S.any help on russian language are welcome...
Reverse graph and find all strongly connected components. Let's component C is first component in topological sort order. If you can reach all other components from C — all cows in C are "popular", otherwise there is no popular cows.
Thanks!