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

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

I wanted to ask which one is better to use because avg. case complexity of set is log(n) while that of unordered_set is o(1) while worst case of set is same but that of unordered set is o(n).

And what are the points that we should take care of while using unordered_set so that we can work with no changes in inbuilt unordered_set?

Any help would be appreciated.

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

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

Unordered_set uses std::hash. You can get more about its cons in this article

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

I suggest you not to use unordered map/set in CF contest for a problem which has large constraints i.e. >= 1e4, because it have chances of being hacked. Better to use custom hashes for unordered_map/set if using as explained in this blog.

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

You may choose either one to use while adapting the problem you are solving.