matbensch's blog

By matbensch, 6 years ago, In English

I can't figure out where I'm going wrong in my solution, which TLEs on case 5. Any help would be greatly appreciated! Here is the link to my submission.

  • Vote: I like it
  • +3
  • Vote: I do not like it

| Write comment?
»
6 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I read your code, I think the time complexity is OK, this might help:

  1. Try to use faster IO
  2. Use less vector and more static array

Here my solution during contest: 90581849, hope it will help you.

»
6 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Don't Pass the vector in dfs call declare it global and clear the vector in each test case

»
6 years ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

pass the adj vector using reference, you are making copy every time thus causing tle