Flight Dependencies

Company: Ethos

Difficulty: medium

Problem Statement

Flight Dependencies A network of flights contains `flight_nodes` flights, numbered `1, 2, ..., flight_nodes`. The dependencies among the flights are given by two arrays, `flight_from[]` (flights leaving a city) and `flight_to[]` (flights arriving in a city). Each pair `(flight_from[i], flight_to[i])` means that flight `flight_from[i]` **depends on** flight `flight_to[i]`: it may depart only after `flight_to[i]` has landed. If a flight is delayed, then every flight that depends on it is also delayed, and this effect continues along the dependencies: a flight that depends on a newly delayed flight is delayed too. You are given `k` flights that are delayed to begin with. Report every flight that ends up delayed, in increasing order of flight number. Input The first line contains two integers `flight_nodes` and `flight_edges`, the number of flights and the number of dependencies. Each of the next `flight_edges` lines contains two integers `u` and `v`, meaning that flight `u` depends on fli