Here is the problem: https://codeforces.net/contest/1980/problem/C and here is my submission: https://codeforces.net/contest/1980/submission/264001404 What did I do wrong?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3839 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | Geothermal | 3569 |
7 | cnnfls_csy | 3569 |
9 | ecnerwala | 3494 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | Um_nik | 164 |
2 | maomao90 | 160 |
3 | -is-this-fft- | 159 |
4 | atcoder_official | 158 |
4 | awoo | 158 |
4 | cry | 158 |
7 | adamant | 155 |
8 | nor | 154 |
9 | TheScrasse | 153 |
10 | maroonrk | 152 |
Here is the problem: https://codeforces.net/contest/1980/problem/C and here is my submission: https://codeforces.net/contest/1980/submission/264001404 What did I do wrong?
Название |
---|
Isn't that highlighted part of code 3*log(m), why are we multiplying the logarithmic operations?
You are right, then the TLE might be because of constant factor being too high.
5.6*10^7, actually. 5.6*10^6 should almost never TLE, but anything times 10^7 can TLE easily with constant factor.
You are using the map's read operation thrice in a loop which goes till M. Then you are using 2 map read operations in a loop which goes till N. Then you have another loop with NLogN complexity. So O(3NLogN + 3MLogM), for the N=M=2*10^5. You are doing close to 2.2 *10^7 operations, which might cause TLE.
Not using Fast IO can also be a factor for TLE.
I submitted your code but with only two different lines , defining
endl
to be”\n"
, and using thefastIO
macro , and it passed Here's the submission 264177806In general avoid using
endl
because it does flushing to the output stream which can cause TLEThis works in two simple ways.
Thank you guys for responding.