unordered set, map running time

Revision en1, by Nakagawa.Kanon, 2019-08-13 07:28:30

Lately I've been submitted codes to Building Skyscrapers. You don't have to understand my code but to better explanation, my first idea is to use unordered set and map to reduce first half of the solutions to $$$O(N)$$$ but it got TLE : 57946506. I've managed to submit again and get 100pt just by get rid of the ordered set (still use the unordered map) and running time reduce from > 3500ms to 2589 ms : 57994251. Finally, I get rid of both of them and just sort the whole vector and use the two pointer in $$$O(NlgN)$$$, the time reduced to 655 ms : 58085217.

I believed there is something wrong with the default hash function. Can anyone improve it ?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Nakagawa.Kanon 2019-08-13 07:28:30 906 Initial revision (published)