题意:一棵树,给两个点,求树上有多少点到他俩距离相等 倍增lca,分好多情况讨论.. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #define N 100500 using namespace std; int e=1,head[N]; struct edge{ int u,v,next; }ed[2*N];…
倍增LCA板子,没有压行,可读性应该还可以.转载请随意. #include <cstdio> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int maxn = 5e5; int n, m, rt; vector<int> G[maxn]; ; ]; int dep[maxn]; void dfs(int u, int fa…
题目描述 Farmer John has installed a new system of pipes to transport milk between the stalls in his barn (), conveniently numbered . Each pipe connects a pair of stalls, and all stalls are connected to each-other via paths of pipes. FJ is pumping milk…