随笔分类 -  图论——树论

摘要:参考 "这里" cpp include include include using namespace std; typedef long long ll; int n, m, ise[100005], fa[100005][19], dep[100005], uu, vv, ww, hea[100 阅读全文
posted @ 2018-04-08 19:14 poorpool 阅读(251) 评论(0) 推荐(0)
摘要:创造一个环出来,可以让环上的边都只访问一次。 对于 $k=1$,答案就是树的直径两边连起来。 倘若 $k=2$,那就先按照 $k=1$ 的求一遍,然后我们发现,如果第二条加的边构成的环和第一条加的边构成的环有交,那么交必定会被访问两次。这样交不但没有减少访问次数,还抵消了第一次的成果。因此把第一次求 阅读全文
posted @ 2018-03-20 18:29 poorpool 阅读(94) 评论(0) 推荐(0)
摘要:重点是求树的直径、半径。 参考 "这里" cpp include include include using namespace std; int n, uu[5005], vv[5005], ww[5005], cnt, hea[5005], zui[5005], cii[5005], dis; 阅读全文
posted @ 2018-03-15 16:00 poorpool 阅读(123) 评论(0) 推荐(0)