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.
№ | Пользователь | Рейтинг |
---|---|---|
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 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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.
Название |
---|
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.