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

Автор Maria386, история, 4 часа назад, По-английски

Ok Code Forces

I realize the error in the previous blog is huge and if I knew how to delete the blog I would have done so. Before I reach the poverty line in the Contribution area again.

But I really have a question this time!

I had written this code (296121982) for 113F but finally by converting the vector to a list I managed to solve this problem(296125493).

But I saw a friend who was able to solve the question with the same process(110436429). Can you guide me?

Thank you in advance.

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

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by Maria386 (previous revision, new revision, compare).

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

figure it out on your own

»
3 часа назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Check your merge function (In the first attempt that you got Memory Limit Exceeded). instead of "-par[v] < -par[u]", use "par[u] > par[v]" since your intention is u>v (if im wrong then sorry again :))

»
3 часа назад, # |
Rev. 3   Проголосовать: нравится -8 Проголосовать: не нравится

shut up why you spam comment section Codeforces is getting TRASHED ALL BECAUSE OF YOU THE FUCK

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

Doing ans[v].clear() doesn't actually free up the memory used by the vector. Adding ans[v].shrink_to_fit() to free up the memory used by ans[v] makes your MLE submission TLE. This means your vector merging probably isn't optimal. Your friend's submission uses something called small-to-large merging, which you can find good explanations for online.

By the way, please ignore the troll comments above. They are just people who have nothing better to do with their time than belittle others.

»
2 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I changed the line if (-par[v] < -par[u]) to if (par[v]<par[u]) and it worked

You probably meant to write if (-par[v] > -par[u])