it is giving TLE in some of test cases
here is link to my code https://cses.fi/paste/3b8de947940f05b018bda3/
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 170 |
2 | Um_nik | 162 |
3 | maomao90 | 161 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 154 |
7 | Dominater069 | 154 |
9 | awoo | 152 |
9 | luogu_official | 152 |
it is giving TLE in some of test cases
here is link to my code https://cses.fi/paste/3b8de947940f05b018bda3/
Name |
---|
Erase function in Vector takes O(n) complexity so it will cause TLE. We have to use ordered set which takes O(log n) complexity for erase function. For more information You Can refer to these links-
https://mirror.codeforces.com/blog/entry/83295?#comment-751599
https://discuss.codechef.com/t/cses-josephus-problem-i-ii-getting-tle/84240
its giving TLE with set also! here is my code using set: https://cses.fi/paste/9abb1e3c5422a39119bcda/
Accepted code link: https://cses.fi/paste/32323f6cf9bbab6019bdd6/