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 | 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 |
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.