Question Link-https://www.hackerearth.com/practice/algorithms/graphs/depth-first-search/practice-problems/3/?sort_by=solved&p_level=
Code link-https://ide.codingblocks.com/s/332973
JP and the Escape Plan Hackerearth
The link you shared does not point to any specific question. Please share the correct link.
https://www.hackerearth.com/practice/algorithms/graphs/depth-first-search/practice-problems/approximate/jp-and-the-escape-planapprox/?layout=old
or Just type JP and Escape Plan Hackerearth in Google ,You will find
Leave it, the testcases are completely wrong. Your solution is completely right.
Even the solution in Editorial does not pass any testcase.
Spent my whole day on this 
ok…