【BZOJ 4753】[JSOI2016] 最佳团体

相关链接

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4753
神犇题解Ⅰ:http://blog.csdn.net/a_crazy_czy/article/details/51761871
神犇题解Ⅱ:http://blog.csdn.net/WorldWide_D/article/details/51565773

解题报告

考虑分数规划的套路的话,先二分一个值
现在问题变成了:在树上选一些点,使得点权和大于等于0
但这题还有一个奇怪的要求:一个点被选,其所有祖先必须被选

这就需要一个姿势非常奇怪的DP:

先将树搞到DFS序上去,设 $r(i)$ 表示第i个点的子树中DFS序最大的那个点
设 $f(i,j)$ 表示处理到了第$i$个点,已经选择了$j$个点
那么转移分两种:

  1. 选择第i+1个点:$f(i+1,j+1) = f(i+1,j+1) + f(i,j) + w_{i+1}$
  2. 不选择第i+1个点:$f(r(i+1)+1,j) = f(r(i+1)+1,j) + f(i,j)$

这样相当于如果不选择第$i$个点的话,就强行跳过他的子树
妙,真是太妙了!

17 thoughts to “【BZOJ 4753】[JSOI2016] 最佳团体”

  1. Thanks for your marvelous posting! I really enjoyed reading it,
    you may be a great author.I will make sure to bookmark your
    blog and will come back at some point. I want to encourage continue your great job, have
    a nice weekend!

  2. Nice post. I learn something totally new and
    challenging on blogs I stumbleupon every day. It will always be useful to read through
    content from other writers and use a little something from their sites.

  3. Do you mind if I quote a couple of your articles as long as I provide credit
    and sources back to your weblog? My blog is in the very same area of interest as yours and my users would
    truly benefit from some of the information you present here.

    Please let me know if this ok with you. Thanks a lot!

  4. Thank you for any other excellent article. Where else could anybody get that type of info in such a perfect approach of writing?
    I have a presentation next week, and I’m at the look for such information.

  5. Hey there, I think your blog might be having browser compatibility issues. When I look at your website in Opera, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!

  6. Hi! Someone in my Facebook group shared this site
    with us so I came to take a look. I’m definitely loving the information. I’m bookmarking and
    will be tweeting this to my followers! Exceptional blog and superb style and design.

  7. I’m not sure where you are getting your info, but good topic.

    I needs to spend some time learning more or understanding more.

    Thanks for fantastic information I was looking for this information for my
    mission.

  8. Please let me know if you’re looking for a article author for
    your weblog. You have some really good articles and I feel I would be a
    good asset. If you ever want to take some of the load off,
    I’d really like to write some articles for your blog in exchange
    for a link back to mine. Please blast me an email if interested.
    Thank you!

  9. Heya i am for the first time here. I found this board and I
    in finding It really useful & it helped me out much.

    I hope to present one thing again and aid others such as you aided me.

  10. Thanks for a marvelous posting! I quite enjoyed reading it, you happen to be a great author.I will always bookmark your blog and definitely will come back later on. I want to encourage that you continue your great posts, have a nice day!

Leave a Reply

Your email address will not be published. Required fields are marked *