| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
| 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]inCand 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.As far as I know, this doesn't actually work because in this problem, edge lengths are allowed to be negative, so the property that the LCA is the lowest-depth node in the range doesn't hold.