首页 > TAG信息列表 > Linova

Linova and Kingdom CodeForces - 1336A

贪心好难啊,不好猜。 这道题的话,易得,如果一个节点是工业区的话,它的子节点也都是工业区,因为否则我们对调该节点和子节点,答案就多了1。所以说是先选子节点在选择父节点作为工业区,同理如果假定全为工业区,我们选择旅游区的话,我们应该先选择父节点为旅游区,所以我们选择策略时要避开这种

CF1336 A. Linova and Kingdom

A. Linova and Kingdom 题意 给你一颗nnn个节点根为1号节点的树,选kkk个城市作为工业城市,其余为旅游城市,工业城市的使节每经过旅游城市开心值+1,求所有工业城市的使节到1号节点的开心值的和最大为多少? 思路 贪心 dfs 很容易看出来如果只选一个,一定选距离根节点最远的叶子,我们

Linova and Kingdom

C - Linova and Kingdom 参考:Codeforces Round #635 Editorial 首先要知道的规律是如果一个城市为工业城市,那么它的所有子节点也肯定为工业城市。可以通过反证法证明。 那么我们可以得到每一个旅游城市的贡献为(子树大小 - 结点深度),证明方法可以查看官方题解。 没有思路的话,可以先

Codeforces 1337C Linova and Kingdom

题意 给你一颗有根树,你要选择\(k\)个点,最大化\(\sum_{i \in S} val_i\),其中\(S\)是被选点的集合,\(val_i\)等于节点\(i\)到根的路径上未被选择点的个数。 解题思路 这题思路挺有意思的。 我们可以逐个点进行选择。新选择一个点对答案的贡献为点到跟的距离减去子树中被选择点的个数

Codeforces Round #635 (Div. 2) C. Linova and Kingdom

https://codeforces.com/contest/1337/problem/C C. Linova and Kingdom Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as s