Please read the new rule regarding the restriction on the use of AI tools. ×

Aspergillus's blog

By Aspergillus, 4 hours ago, In English

This problem was the first time I encountered a problem of DP on trees, and even with a decent amount of practice in DP, the states similar to that of "maximim score in the subtree of j considering j is taken or not", did not occur to me during the contest probably because such a state breaks quite easily when the coins are taken from let's say all the neighbours at a distance of <= 2.

This is the best I could come up with for the above variation:

given a tree and it's node values, you can pick a node but all it's neighbours upto a distance of 2 gets subtracted by c, find max sum of node values you can achieve

The above solution is wrong for the above problem, counterexamples are plenty. The reason is because the code only takes care of influence of children passed onto its parents, however it is easy to see that a node once picked not only influences it's children and parent, but also it's siblings, which is not taken care of. This is where the difference from the actual problem becomes apparent. Influence upto one units do not affect the siblings, hence the same state works for neighbour-only influence.

As a side effect however, the code works perfectly for a linear graph, i.e a tree with single children only, thus this code can be thought of as the solution to the problem when we have an array and we can pick elements at the cost of reducing it's neighbours upto 2 indices on both sides by c, with the goal to maximise the score.

Anyone knows any standard procedure for such problems?

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

»
4 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Very hard problem...