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

Автор bharatim1221, история, 3 года назад, По-английски

Please help me out. I'm getting "Memory Limit exceeded in test 3" in question D of codeforces https://mirror.codeforces.com/problemset/problem/1675/D. I can't figure out where I'm doing wrong. Kindly help me out.

I'm attaching my code here. https://mirror.codeforces.com/contest/1675/submission/156122315.

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

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

You are cloning the tree data every time you call dfs() function.

Try something like this:

void dfs(vector<vector<ll>>& tree, ll v)
»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

A small note for you:

These type of questions can be asked in the tutorial blog of that contest. Creating a new blog to ask about simple problems with your solution is disturbing for the community as all the posts appear in the homepage as long as it's active.

Don't take it personally. Thanks.