https://mirror.codeforces.com/contest/1691/submission/159098417
Why does this solution fail on test 30 (TLE)? this is an O(n) solution and also this shouldn't have run more then O(1) time complexity.
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Name |
---|
This TLE is repeated more and more nowadays in codeforces and the reason is same.
I just replace unordered_map with map and it get accepted
unordered_map cause TLE because of its bad hashing function, but to override this you can check this blog for most efficient custom hashing.
upd: accepted code using unordered_map with custom hash.
Thank you very much I thought using using unordered_map will give me a lesser time complexity