加入设置
心得
把f看做什么
代码
# # # # # # # # #(一、一、二)为;structnote{intto,next };注边[N * 2];inttot,head[N];inti,j,k,l,n,m,ans,wz;intx,y;intval[N],fa[N];多色调[N];multisetint:iteratoruboolpintread(){intrs0,fhcharchwhile((ch0||ch9)(ch^-))chgetchar();if(ch-)fh-1,chgetchar();while(ch0ch9)rs(rs3)(rs1)(ch^0),chgetchar();returnfh * rs}voidlb(intx,inty){edge[tot].todge[tot].下一个标题[x];head[x]tot;}voidmerge(intx,inty){if(s[x]).大小(s)[y].size())swap(s[x],s[y]);for(us[x]).begin();u!s[x].end();u)s[y].插入(* u);s[x].clear();} void DG(intx){ inti;for(ihead[x];我;iedge[i].下一个){if(fa[x]edge[i].到)继续;边缘.至]dg(edge[i]).to);合并(边缘[i].to,x);}us[x].上限(val[x]);if(u!s[x].end())s[x].erase(u);s[x].insert(val[x]);}intmain(){freopen(simple.in,r,stdin);freopen(simple.out,w,stdout);nread();fo(i,1,n)val[I]-read();fo(i,1,n-1){ xford();yread();lb(x,y);lb(y,x);} DG(1);printf(%d,n-s[1]).size());返回0;}
相关阅读
标签: #5610相关文章最新报道