Problem Info

CSES Flight Routes Solution page


In the main idea section of the solution, it states " The theorem used here is that if one vertex can both reach and be reached by all others, then every vertex in this graph can reach all others."

Is it supposed to be iff not just if? If it is “if” then how would it suffice in the solution to dfs only at 0?


Could you please elaborate on what you mean?

I’m not sure what are you are confused about. Are you saying that you think the solution is wrong (if so, on what case)?

Both “if” and “iff” would be correct here. We can choose any vertex to run both the forward and backward DFS and from. It doesn’t have to be 0.