Oh hi Codeforces. I'm doing problem Longest Flight Route. At first I'm like "hum ... directed graph but with no circle, gotta find the longest path from 1 to n using normal BFS and I'm gonna be find ...". So it turned out that I didn't get AC because somehow I got TLE verdict on 2 test cases ... I checked the runtime of other test and saw that longest runtime for other test that got AC is like 0.09 sec so it must my algorithm's fault. I did some more check and found that something has caused my BFS to run like forever. However, it's not possible I think. My solution is just the reversed version of normal BFS : with current node u and it's child v, I check if (d[v] < d[u]+1) then update d[v], push v in the queue and I'm done (Oh sorry, I should have mention that d[i] is the longest path from 1 to i). This graph is guaranteed to have no circle, so how the heck did my code got 2 TLE
Pls leave some of your thought about this problem and what should I do to fix my code ... Can't see why BFS run forever.