Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <cmath>#include <algorithm>#include <queue>#include <stack>#include <vector>using namespace std;long long sum1[100005],to[200005],head[100005],nex[200005],u,v,s,a[100005],vis[100005],ed_num,n,ans,sum[100005];void addedge(long long fro,long long too){to[ed_num]=too;nex[ed_num]=head[fro];head[fro]=ed_num;ed_num++;}void dfs(long long now,long long fa){vis[now]=1;if (sum1[now]==0) return;for (long long ee=head[now];ee!=-1;ee=nex[ee]){if (!vis[to[ee]]){dfs(to[ee],now);}}if (a[now]<=0) {a[fa]+=a[now]-1; a[now]=1;}