Hello all,
I have read segment tree, lazy propagation tutorials. but I find difficult to solve some problems like this one. Can anyone give more necessary tutorials or problems links to master segment tree?
Thanks in advance.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | orzdevinwang | 3844 |
3 | jqdai0815 | 3682 |
4 | jiangly | 3618 |
5 | Benq | 3529 |
6 | ksun48 | 3489 |
7 | Radewoosh | 3483 |
8 | Kevin114514 | 3443 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | atcoder_official | 162 |
3 | maomao90 | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | djm03178 | 152 |
Hello all,
I have read segment tree, lazy propagation tutorials. but I find difficult to solve some problems like this one. Can anyone give more necessary tutorials or problems links to master segment tree?
Thanks in advance.
Name |
---|
Algorithm Gym :: Everything About Segment Trees This is a very good tutorial. Enjoy it !!
That problem can be solved with a self-balancing BST in O(NlogN) or with a segment tree in O(Nlog2N) as far as I know.
There is a O(NlogN) solution with segment tree.
You're right, I didn't give it much time. When you traverse the tree, you decide to go left or right depending on the number of elements on each interval, so it's NlogN effectively. I was actually thinking in the O(Nlog2N) solution using BIT when I said "segment tree".
Hi, I had an idea, but I am terrible at implementation, so can you help ensuring if my approach will be correct? or Is there any valid similar approach?
Thanks!
If at the end of all your steps, you get a query (c,3), you have cnt[3] = 1, so you will print A[3+1] = -1, while the correct answer is to print A[5]. With BIT, you would need to do O(log2N) per query, though you can achieve O(logN) using segment tree by storing in each node the total number of people in that range.
I think it uses order statics. Each node of segment tree can store the number of active soldiers in the line.
fffuuuu!
https://www.hackerearth.com/notes/segment-tree-and-lazy-propagation/
You are legendary grossmeister, you must know everything about segment trees.