摘要: ###题意 树上每个结点的权值为$w_i$,若点$i$和点$j$满足:$i$和$j$的最短距离为2,则会产生$ w_i * w_j $的联合权值。 求最大联合权值和联合权值之和。 ###分析 ①最大联合权值 对于结点$u$,$u$的叶节点之间一定能产生联合权值。 那么与$u$相连的所有点之间都能产生 阅读全文
posted @ 2022-10-20 17:16 SxtoxA 阅读(40) 评论(0) 推荐(0)
摘要: (以洛谷P3379为例) 其中: dep[u]:表示结点u的深度 dp[u][k]:表示结点u的2^k祖先 代码: #include<iostream> #include<cstdio> #include<cstring> const int maxn = 500000 + 10; int nxt[ 阅读全文
posted @ 2022-10-20 16:32 SxtoxA 阅读(22) 评论(0) 推荐(0)
12 13