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.
№ | Пользователь | Рейтинг |
---|---|---|
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 | gyh20 | 3447 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | awoo | 161 |
2 | maomao90 | 160 |
3 | cry | 157 |
3 | nor | 157 |
5 | atcoder_official | 156 |
6 | -is-this-fft- | 155 |
7 | maroonrk | 154 |
8 | adamant | 153 |
9 | Um_nik | 152 |
10 | djm03178 | 146 |
Название |
---|
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