I am trying to solve this problem on codechef https://www.codechef.com/problems/TRIP.
My code is :- https://ideone.com/ZgA0yr
I am not sure why am I getting TLE. Any help would be great.
P.S: Code is small to go through so please go through it if possible.