# | 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 |
Name |
---|
Auto comment: topic has been updated by fsociety00 (previous revision, new revision, compare).
You may try a segment tree on the euler tour.You need to understand the euler tour/rmq algorithm for lca first (it can be found here https://en.wikipedia.org/wiki/Lowest_common_ancestor ).Then,build a segment tree holding the maximum value of
lev[node1]-2*lev[node2]+lev[node3]
where node1 and node3 are at first occurrence,both are white and node2 can be found between them(and is not neccesarily white)-lev[x]
denotes the level of node x.Of course,you need to maintain some helping values (e.g maximum oflev[node1]-2*lev[node2]
) but I find this a good segment tree exercise.Finally, you get O(logn) per update.Can you please Elaborate on how to Maintain the Structure. A submission Code would be Extremely Helpful.
This function 'merges' 2 segment nodes(you now the answers for
[a;b]
inB
,for[b+1;c]
inC
and you get them for[a,c]
inA
.I'm sorry it isn't very explicit, but i'll try to explain which is every part of the structure.The rest of the segment tree and building euler tour is more of a prequisite and I would PM if requested, but I find the most important part here.