Hi there, i am stuck at the problem Codeforces Eductional Round 6 I read the tutorial and tried implementing the same, here is my Code. I think the problem is with the lazy propagation, please try to find the mistake.
# | 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 |
Hi there, i am stuck at the problem Codeforces Eductional Round 6 I read the tutorial and tried implementing the same, here is my Code. I think the problem is with the lazy propagation, please try to find the mistake.
Name |
---|
__builtin_popcount(mask) works with ints, you should use __builtin_popcountll(mask) instead.
Also, I think that if for some vertex v its parent has a greater label, then your segment tree initialization isn't correct. But I'm not sure.
And an observation not so important: You don't need the "complete" Euler tour, you could add vertices only at discovery time.
Hi pulgares, thanks for the __builtin_popcountll(mask) thing, would have stuck at this forever. I checked the initialization(2 times), it looks fine to me, maybe you want pass me a small test cases
I fail to catch this completely(but this fact looks quite interesting), i agree that we don't need to store euler tour for filling up starting and ending index of each vertex in euler tour, but we still need it to query over a subsegment which represent the subtree of a given vertex, or are you trying to imply that there is more cleaner/shorter/swaggy way to do it(please say yes) ?
if we add vertices only at the discovery time, then how would we know the range of updation, obviously the node in the subtree of a vertex would get discovered after it, but so will other node which are not, so how will we decide till which index in th euler tour array we have to update the values ?
there, your code gives 2 as the answer and should be 3.
"please say yes" haha sorry :p What I suggest is pretty much the same, every subtree is a subsegment of the array. In the dfs you add the vertex only at discovery time and the segment of its subtree is from there to the last vertex of its subtree, I think you can delete these two lines
from your dfs loop and it will work as I suggest.