注意到不动点个数等价于数组的Mex,使用树上启发式合并(DSU on Tree) 统计每个子树的Mex累加即可。 ///*****Sellaris*****/// #include <bits/stdc++.h> #define ll long long #define x first #define y second typedef unsigned long long ull; typedef std::pair<int,int> pii; using namespace std; const int maxn=3e5+10; const int mo=1e9+7;...