burakcetin's blog

By burakcetin, 10 years ago, In English

516D - Drazil и утренняя зарядка

Hello everyone. I really need some help with this question. I have implemented 3 different solutions. And if there is a logical mistake in them i am ready to code another one from beginning so i will appreciate any kind of help. At each one of them my code calculates the far array from tutorial. That part is same in all of them.

1) 9946947

On this one i used maps for each node. This one having TLE(unfortunately) but at least i know the far array is correct because this code passed some cases.

2) 9946947

This one calculates when should nodes get popped out from groups with a binary search on a stack as said in tutorial. Then while in dfs3 function it increases a point for the node we find on binary search. And it sums all return values of each child adds one and decreases sum by the point of that node(because we are in the point where some nodes should be kicked out and for that nodes we added a point in this node). And the answer is the biggest return value it have found while dfs. This one gets WA but gives the same answer with the next one so i think they have a common mistake in a way.

3) 9969062

This one uses a segment tree on the tree we have using discovery and finish times. At each node of segment tree there is a sorted vector so i can binary search the number of the nodes which have far value lesser then far[root]+l. As i said this one gives the same output with the previous one so i think there is something common but only thing they have common is calculating the far array and that part must be correct(??) because of the first code. It might be about long long thats the only theory i have right now.

TL;DR: You can ignore the submissions if you want and give me another way to solve this problem.

Thanks!

  • Vote: I like it
  • +5
  • Vote: I do not like it