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

Автор LunaticPriest, история, 5 лет назад, По-английски

Hello, I'm solving a basic connected components . My code is this . I tried switching to bitsets and a map instead of vectors, and also wrote my dfs iteratively in case of stack overflow. What can be the problem? Thanks!

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

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

You are using O(n^2) amounts of memory, which is too much.

When you try to access an element in a map in c++, if the element isn't there the default value of that element is inserted into the map, so your dfs blows up the memory.