并查集的基础题。总共n个人,有m组人有相同信仰。问这些人中存在的信仰最多有多少种。 1 #include<cstdio> 2 #include<string.h> 3 #include<iostream> 4 using namespace std; 5 const int maxn=50001; 6 int p[maxn],rank[maxn]; 7 bool vis[maxn]; 8 9 int find(int v)10 {11 if(p[v]==v)12 return v;13 else14 {15 p[v]=find(p[v]);16... Read More
posted @ 2013-06-03 11:47 longlongago Views(113) Comments(0) Diggs(0) Edit