并查集poj1611The Suspects
#includeusing namespace std;const int MAX=30010;int pre[MAX];void init(int n){ for(int i=0;i<n;i++) pre[i]=i;}int find(int x){ if(pre[x]==x) return x; return pre[x]=find(pre[x]);}void unit