You have n cities and m one-way flights. You want to check if you can travel from any city to any other city using flights. If yes, output "YES". If no, output "NO" and give an example of two cities where travel is impossible.
This is the definition of strong connectivity in directed graphs. If the graph is strongly connected, every node can reach every other node. Run Kosaraju's or Tarjan's SCC algorithm to check if there is exactly one strongly connected component.