摘要:hdu1856: http://acm.hdu.edu.cn/showproblem.php?pid=1856题意:输入n对朋友,求最多的朋友集合(直接或间接为朋友)解法:并查集:集合的合并及查询。code:#include<iostream>#include<cstdio>#include<cstdlib>const int maxn=10000002;int fa[maxn],ans[maxn];int find(int x) //路径压缩,复杂度为常数{ int fx=fa[x]; if(x!=fx)fa[x]=find(fx); return fa[
阅读全文
posted @ 2012-07-25 20:54
浙公网安备 33010602011771号