http://usaco.org/index.php?page=viewproblem2&cpid=360

PLEASE EXPLAIN WHAT DOES THIS PROBLEM WANT US TO FIND??

http://usaco.org/index.php?page=viewproblem2&cpid=360

PLEASE EXPLAIN WHAT DOES THIS PROBLEM WANT US TO FIND??

You just need to find the no. of pairs of wormholes which when joined would lead to an infinite loop in the x-direction (because that’s the direction of cow movement). I think it can be done by counting pairs with same y-coordinates. But don’t really know how to do it much efficiently.

Even im stuck on this. Counting only pairs with same y-coords wont help as far as i understand (See the example). I felt its more of loop finding using bellman ford.