![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
图论--树的直径
妖怪吧
这个作者很懒,什么都没留下…
展开
-
BZOJ 1099 树网的核
题面 解题思路 搞了三个多小时,最后bzoj还是T,我能说什么。。。 noip数据很水,直接暴力n^3过。 我们考虑优化,首先可以贪心,我们要在直径上选肯定越插长越好,所以n^2其实就可以解决。但这还不够,根据直径的最长性,我们可以用一个单调队列优化。可以做到O(n),但bzoj T了,可能是我太弱了吧。 代码 #include<iostream> #include...原创 2018-07-08 10:07:25 · 197 阅读 · 0 评论 -
poj 1985 Cow Marathon
题面 解题思路 树的直径模板,用树形dp来求,dp[x]表示以x为端点的最大子链长度,d[x]=max(d[y]) (y是x的后继) 代码 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int原创 2018-07-06 21:22:39 · 111 阅读 · 0 评论