Help Needed In CSES Graph Problem Longest Routes

Правка en2, от Gagandeep98, 2020-06-05 17:13:27

My logic is giving WA on 50% of the test cases. I am not able to figure out what is wrong with my logic. Any help would be great.

Logic: I apply a regular dfs, and return true or false. True indicates, that it is indeed the shortest the path, while false indicates, that it is not. If we get a true, then we update the parent node, else we don't.

Code: Code

UPDATE: Solved using DP but would be curious to know, if anyone can do it without DP.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Gagandeep98 2020-06-05 17:13:27 89
en1 Английский Gagandeep98 2020-06-05 16:33:21 440 Initial revision (published)