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

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

Hello everyone!

Today I found a weird thing. I was solving problem C from Educational Codeforces Round 115. The link for the same is here. 1598C - Delete Two Elements I have solved this problem using map. The link to my solution using map is here: map solution But it was consuming more time. So I decided to reduce it. Then I realized that I actually do not want the ordered map. So, I have just replaced map with unordered_map. The link to my solution using unordered_map is here: unordered_map solution But surprisingly, I got TLE on test case 14. I don't know the reason behind this. Can anyone explain me why this happened?

Thank you :)

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

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

map guarantees the TC of O(log n) while unordered_map may go to O(n) for some inputs, and there are different ways to deal with that.

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

dfghjkolp;lkjhgfghju

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