http://acm.hdu.edu.cn/showproblem.php?pid=3038 就是给你x,y,z让[x,y]的和为z; 问顺序下去有多少错; 这可以看出并查集,就是y比x-1大z 然后如果y,z-1在同一个集合,直接验证答案; 不然就把他们合起来; 为了路径压缩,我们就要链接x-1,y的祖先; 当然我们链接x-1,y祖先的时候要保证x-1,y的距离...
However, TT is a nice and lovely girl. She doesn't have the heart to be hard onFF. To save time, she guarantees that the answers are all right if there is nological mistakes indeed. What's more, if FF finds an answer to be wrong, he will ignore it when judgingnext answers. But...
}returnfa[x]; }intmain() {intn,m;while(~scanf("%d%d",&n,&m)){for(inti=0;i<=n;i++){ fa[i]=i; sum[i]=0; }intans=0;while(m--){inta=read(),b=read(),w=read(); a--;intrta=Find(a);intrtb=Find(b);if(rta==rtb){if(sum[a]-sum[b]!=w)ans++; }else{ fa[r...