正文
增加 3 行删除 3 行
1234567891031 行未改动42434445464748495094 行未改动145146147148149150151152153112 行未改动全部展开前言:100 + 95 + 100 + 0## [T1](https://www.luogu.com.cn/problem/T719650contestId=302468):没什么好讲的,树链剖分基础知识考察```cpp#include<bits/stdc++.h>#define int long longusing namespace std;const int N = 2e5 + 5;int n, cnt, siz[N], son[N], dep[N], fa[N], dfn[N], top[N], seg[N];31 行未改动## [T2](https://www.luogu.com.cn/problem/T719652?contestId=302468):错误原因:老师数据锅了思路:树链剖分后,直接线段树上区间修改+单点查询```cpp#include<bits/stdc++.h>#define int long longusing namespace std;const int N = 1e5 + 5;int n, q, cnt, siz[N], son[N], dep[N], fa[N], dfn[N], top[N], seg[N];94 行未改动思路:为了方便数数量(实际上就是最短距离),将黑边设为0,将白边设为1,则对于两个点若要联通,则他们的树上最短路径的边权和一定为0,否则输出-1即可,顺带一提,如果要求最短路径长度,在lca过程中可以一起算,不过这里直接使用了距离公式```cpp#include<bits/stdc++.h>#define int long longusing namespace std;const int N = 1e5 + 5;int n, q, cnt, p[N], siz[N], son[N], dep[N], fa[N], dfn[N], top[N], seg[N];112 行未改动全部展开1234567891031 行未改动42434445464748495094 行未改动145146147148149150151152153112 行未改动全部展开前言:100 + 95 + 100 + 0## [T1](https://www.luogu.com.cn/problem/T719650contestId=302468):没什么好讲的,树链剖分基础知识考察```cpp#include<bits/stdc++.h>#define int long longusing namespace std;const int N = 2e5 + 5;int n, cnt, siz[N], son[N], dep[N], fa[N], dfn[N], top[N], seg[N];31 行未改动## [T2](https://www.luogu.com.cn/problem/T719652?contestId=302468):错误原因:老师数据锅了思路:树链剖分后,直接线段树上区间修改+单点查询```cpp#include<bits/stdc++.h>#define int long longusing namespace std;const int N = 1e5 + 5;int n, q, cnt, siz[N], son[N], dep[N], fa[N], dfn[N], top[N], seg[N];94 行未改动思路:为了方便数数量(实际上就是最短距离),将黑边设为0,将白边设为1,则对于两个点若要联通,则他们的树上最短路径的边权和一定为0,否则输出-1即可,顺带一提,如果要求最短路径长度,在lca过程中可以一起算,不过这里直接使用了距离公式```cpp#include<bits/stdc++.h>#define int long longusing namespace std;const int N = 1e5 + 5;int n, q, cnt, p[N], siz[N], son[N], dep[N], fa[N], dfn[N], top[N], seg[N];112 行未改动全部展开