My slow solution 291665439 to 2031D - Пенчик и пустынный кролик passes the system tests.
Explanation
# | 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 | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
My slow solution 291665439 to 2031D - Пенчик и пустынный кролик passes the system tests.
The queue q
contains sets of trees that are reachable from each other. Each set is represented by the index of the tallest tree in that set. For each tree, I iterate through and update q
. This solution should fail when n
is large and a
is sorted, since then every set consists of a single tree.
Name |
---|
my
O(n^2)
brute force solution 291699055 also got accepted for 2031B - Пенчик и палочки для сатэThis is actually a valid $$$\mathcal{O}(n)$$$ solution. With the
if
condition any element will not move more than one place from the initial order so the loop never runs more than twice through the entire array.You are right, I missed that part. Thank you for the explanation! ^_^
Sir, teach us your skill of optimizing code!
Not sure what you mean
Teach us to make slow solutions pass the system tests
oh haha