Question Link - CodeChef: Practical coding for everyone
My Solution Link - CodeChef: Practical coding for everyone
I am trying to do this question using Strongly Connected Components. Any idea on how to optimize code more for not getting TLE in last case ?