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 | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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.