https://codeforces.me/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.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3773 |
3 | Radewoosh | 3646 |
4 | ecnerwala | 3624 |
5 | jqdai0815 | 3620 |
5 | Benq | 3620 |
7 | orzdevinwang | 3612 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | Um_nik | 163 |
2 | cry | 161 |
3 | maomao90 | 160 |
4 | -is-this-fft- | 159 |
5 | awoo | 158 |
5 | atcoder_official | 158 |
7 | adamant | 155 |
8 | nor | 154 |
9 | maroonrk | 152 |
10 | Dominater069 | 149 |
Название |
---|
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