Блог пользователя matbensch

Автор matbensch, 6 лет назад, По-английски

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.

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

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 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

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

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

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