标签:size can ++ highlight nbsp div ++i ace scan
code:
#include <bits/stdc++.h> #define N 100005 #define setIO(s) freopen(s".in","r",stdin) using namespace std; int n,edges; double f[N]; int hd[N],to[N<<1],nex[N<<1],size[N]; void add(int u,int v) { nex[++edges]=hd[u],hd[u]=edges,to[edges]=v; } void dfs1(int u,int ff) { size[u]=1; for(int i=hd[u];i;i=nex[i]) if(to[i]!=ff) dfs1(to[i],u), size[u]+=size[to[i]]; } void dfs2(int um) int main() { setIO("input"); int i,j; scanf("%d",&n); for(i=1;i<n;++i) { int u,v; scanf("%d%d",&u,&v); add(u,v), add(v,u); } dfs1(1,0); return 0; }
标签:size can ++ highlight nbsp div ++i ace scan
原文地址:https://www.cnblogs.com/guangheli/p/11794842.html