倍增法求树中的LCA 洛谷 P3379模板题
倍增法求树中的LCA
第一次。。我用STL中的vector,然后由两个点TLE了。。。无奈只好选择用链表存边
现附上TLE代码(开O2可过):
#include <bits/stdc++.h>
using namespace std;
const int maxn=5e5+7;
int n,m,s;
int lg[maxn],fa[maxn][22],depth[maxn];//fa[...
原创
2019-11-17 23:08:54 ·
146 阅读 ·
0 评论