Help needed to solve SPOJ question ADACYCLE.

Revision en1, by ameyanator, 2018-02-14 09:43:44

I've been trying to solve this question, but I keep on getting a TLE. At first I had an O(V*(E+V)) approach (link). Then I optimized my code so that I store the results of other nodes while calculating the answer of some node. (link). I'm still getting an TLE.

Can anyone please suggest another optimization/approach for this question so that I can get an AC?

Tags spoj, #help, adacycle

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ameyanator 2018-02-14 09:45:46 14
en1 English ameyanator 2018-02-14 09:43:44 494 Initial revision (published)