题目
思路:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define pb push_back
#define lson p << 1
#define rson p << 1 | 1
#define fi first
#define se second
const int maxn = 1e6 + 5, maxm = 5e3 + 5;
int a[maxn], b[maxn];
int n, m;
string s;
vector<int> G[maxn];
int siz[maxn];void dfs2(int u){siz[u] = 1;for(auto v : G[u]){dfs2(v);siz[u] += siz[v];}
}int dfs(int u, int k){int tot = 0;int id = 0;for(auto v : G[u]){tot += siz[v];if(!id || siz[v] > siz[id]){id = v;}}if(siz[id] - k <= tot - siz[id]){return (tot - k) / 2;}int add &#