My slow solution 291665439 to 2031D - Penchick and Desert Rabbit passes the system tests.
Explanation
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 165 |
2 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
4 | adamant | 160 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
8 | Dominater069 | 154 |
8 | nor | 154 |
My slow solution 291665439 to 2031D - Penchick and Desert Rabbit 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 - Penchick and Satay SticksThis 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.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