Is normal set faster than unordered_set??

Revision en1, by GreatRevan, 2025-04-26 20:06:14

I thought unordered_set was faster because it doesn't need to deal with sorting.

I got accepted for problem C on a recent Div.3 contest, but it returned as TLE on test 17 after contest finished and I lost 52 points. You know what's funny? When you replace unordered_set with normal set, it gives accepted (sorting ability of normal set doesn't help you for this problem)

Code with unordered_set (TLE on test 17): https://mirror.codeforces.com/contest/2106/submission/317003071

Same code with normal set (Accepted): https://mirror.codeforces.com/contest/2106/submission/317364054

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English GreatRevan 2025-04-26 20:06:14 618 Initial revision (published)