参考解题http://wenku.baidu.com/view/d94699d8a58da0116c17496e.html
r[x]表示x与集合的代表元素之间的关系,0:同类; 1,被吃; 2 吃
#include<iostream>
#include<cstdio>
using namespace std;
int father[50001],r[50005];
int getfather(int x)
{
if(x==father[x])
return x;
int t=father[x];
father[x]=getfather(father[x]);
r[x]