摘要: 代码 #include<bits/stdc++.h> #define int long long using namespace std; int n,m,r,p; int dep[114514]; int fa[114514]; int son[114514]; int siz[114514]; 阅读全文
posted @ 2025-05-23 20:05 Loyal_Soldier 阅读(22) 评论(3) 推荐(0)
摘要: 倍增 时间复杂度 \(O(n\log n)\)。 代码 #include<bits/stdc++.h> using namespace std; int anc[500010][21];//anc[i][j]表示i节点的2^j级祖先 int n,m,s; int d[500010];//d数组表示当 阅读全文
posted @ 2025-05-23 20:02 Loyal_Soldier 阅读(15) 评论(0) 推荐(0)