"Mysterious" low running speed in Java

Revision en2, by Tom--CCS, 2018-06-28 16:15:23

Recently in Educational Codeforces round 46 I wrote the following programme for 1000E - Нужно больше боссов in Java:

39737014

Now I am pretty sure that the program runs in O(n + m) time(it is a dfs plus an iteration over the edges). However, the program got rejected due to Time Limit Exceeded despite its optimal asymptotic efficiency. Would anyone point out which part of my programme is consuming lots of time? I am a newbie in programming and really appreciate any help!

Update: Thank you all for giving me advice! I have solved the problem.

Tags java, time

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Tom--CCS 2018-06-28 16:15:23 74
en1 English Tom--CCS 2018-06-28 15:51:29 519 Initial revision (published)