摘要: 树上边的差分,给每个点赋值为0,对于非树边(x,y)x,y权值+1,lca(x,y)-=2,再dfs #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #define MN 200050 using 阅读全文
posted @ 2019-06-03 15:38 红色OI再临 阅读(174) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; int dfn[500001], f[500001][21]; int n, m, cnt, root; int head[500001], lg[500001]; struct tu { int v, nxt; } e[5000001]; void add(int u, int v) ... 阅读全文
posted @ 2019-06-03 13:58 红色OI再临 阅读(123) 评论(0) 推荐(0) 编辑