Why does unordered maps gives TLE ?

Revision en1, by coder_ISM, 2024-10-23 09:26:11

Is it me or it happens with everyone that when you are using unordered map in hope that it will reduce your time complexity but in contrast it gives you TLE whereas if you use ordered map it gets accepted.

One thing I am aware of is that its generally not recommended to use auto for loops on unordered map but let me give you an example Question :- https://codeforces.net/contest/1971/problem/G Submission-1 :- https://codeforces.net/contest/1971/submission/287463963 Submission-2 :- https://codeforces.net/contest/1971/submission/287464168 The only difference in both submissions is that in previous one I am using unordered map and I am getting a TLE on TC 22 whereas the second one is getting submitted where I am using ordered map. Just to clarify I am not operating any auto loops on map you can even cross-check in my submissions.

Is this a technical glitch or is there any explanation behind this ? (If you know anything please comment below it will be really helpful :) )

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English coder_ISM 2024-10-23 09:26:11 1031 Initial revision (published)