Need approach to solve this problem

https://www.codechef.com/PROC2020/problems/TIMET

can someone tell me what logic i can use to solve this problem?..

Detect Negative cycle in graph.
If found. Print YES
else NO
Use this for reference.

1 Like

You can use Floyd-Warshall to find distances between all the edges and then for each pair check if Dist(u, v) + Dist(v, u) < 0.
My solution link:
https://www.codechef.com/viewsolution/34917924

1 Like