Recently in Educational Codeforces round 46 I wrote the following programme for [problem:1000E] in Java:↵
↵
[submission: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.
↵
[submission: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.