正文
增加 15 行删除 13 行
1234567880 行未改动8990919293949596977 行未改动10510610710810911011111211354 行未改动16816917017117217317417517614 行未改动1911921931941951961971981998 行未改动20820921021121221321421521684 行未改动3013023033043053063073083097 行未改动31731831932032132232332432585 行未改动4114124134144154164174184198 行未改动428429430431432433434435436120 行未改动全部展开55755855956056156256356456556656756856957016 行未改动5875885895905915925935945958 行未改动604605606607608609610介绍了 $5$ 种求最近公共祖先的方法。看情况未来添加 tarjin 和 LCT 求 $\text{lca}$ 的笔记。---### 倍增80 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){7 行未改动cin >> x >> y;cout << lca(x,y) << endl;}return 0;}```::::---54 行未改动}inline void dfs2(int x,int t){top[x] = t,id[x] = ++cnt;if(!wson[x]) return;dfs2(wson[x],t);14 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){8 行未改动cin >> x >> y;cout << lca(x,y) << endl;}return 0;}```::::---84 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){7 行未改动cin >> x >> y;cout << lca(x,y) << endl;}return 0;}```::::---85 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){8 行未改动if(x == y) cout << x << endl;else cout << lca(x,y) << endl;}return 0;}```::::---120 行未改动全部展开inline void dfs(int x,int father){dep[x] = dep[father] + 1;fa[x] = father;int p = lb[father],q = lb[p];if(dep[father] - dep[p] != dep[p] - dep[q])lb[x] = father;else lb[x] = q;for(int i = pre[x]; i; i=e[i].ne){int y = e[i].to;if(y != father) dfs(y,x);}16 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){8 行未改动if(x == y) cout << x << endl;else cout << lca(x,y) << endl;}return 0;}```::::1234567891080 行未改动9192939495969798997 行未改动10710810911011111211311411554 行未改动17017117217317417517617717814 行未改动1931941951961971981992002018 行未改动21021121221321421521621721884 行未改动3033043053063073083093103117 行未改动31932032132232332432532632785 行未改动4134144154164174184194204218 行未改动430431432433434435436437438120 行未改动全部展开55956056156256356456556656756856957057157216 行未改动5895905915925935945955965978 行未改动606607608609610611612介绍了 $5$ 种求最近公共祖先的方法。看情况未来添加 tarjin 和 LCT 求 $\text{lca}$ 的笔记。斜二倍增给出详细证明,有笔误欢迎提出。---### 倍增80 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){7 行未改动cin >> x >> y;cout << lca(x,y) << endl;}return 0;}```::::---54 行未改动}inline void dfs2(int x,int t){top[x] = t,id[x] = ++cnt;if(!wson[x]) return;dfs2(wson[x],t);14 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){8 行未改动cin >> x >> y;cout << lca(x,y) << endl;}return 0;}```::::---84 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){7 行未改动cin >> x >> y;cout << lca(x,y) << endl;}return 0;}```::::---85 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){8 行未改动if(x == y) cout << x << endl;else cout << lca(x,y) << endl;}return 0;}```::::---120 行未改动全部展开inline void dfs(int x,int father){dep[x] = dep[father] + 1;fa[x] = father;int p = lb[father],q = lb[p];if(dep[father] - dep[p] != dep[p] - dep[q])lb[x] = father;else lb[x] = q;for(int i = pre[x]; i; i=e[i].ne){int y = e[i].to;if(y != father) dfs(y,x);}16 行未改动signed main(){ios::sync_with_stdio(0);cin.tie(0);cin >> n >> m >> s;int x,y;for(int i = 1; i < n; i++){8 行未改动if(x == y) cout << x << endl;else cout << lca(x,y) << endl;}return 0;}```::::