How to improve performance of std::unordered_map

Revision en1, by AnotherRound, 2016-05-06 12:29:29

After getting TLE on test 132 for problem C on CF #350, I tried to optimise. I was surprised when I got AC, because the only thing I needed to change was to replace std::unordered_map with std::map. Does anyone have ideas what causes the different performance? I expected that unordered_map should be faster that map, but it is not the case. Here are both submissions:

AC — map: http://codeforces.net/contest/670/submission/17757996

TLE — unordered_map: http://codeforces.net/contest/670/submission/17730894

Tags map, unordered_map

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English AnotherRound 2016-05-06 12:33:26 52
en1 English AnotherRound 2016-05-06 12:29:29 575 Initial revision (published)