  # HDOJ3926：Hand in hand——并查集、同构图应用

Problem Description
In order to get rid of Conan, Kaitou KID disguises himself as a teacher in the kindergarten. He knows kids love games and works out a new game called “hand in hand”.

Initially kids run on the playground randomly. When Kid says “stop”, kids catch others’ hands immediately. One hand can catch any other hand randomly. It’s weird to have more than two hands get together so one hand grabs at most one other hand. After kids stop moving they form a graph.

Everybody takes a look at the graph and repeat the above steps again to form another graph. Now Kid has a question for his kids: “Are the two graph isomorphism?”

Input
The first line contains a single positive integer T( T D_Double同学的。

```#include
#include
#include
#include
#include
#include
using namespace std;
const int maxN = 10001;

int n, m, n2, m2;
int father[maxN], PT[maxN], isCircle[maxN];
//memset(0, isCircle, sizeof(isCircle));
struct node
{
int num, isCircle;
friend bool operator b.num;
return a.isCircle>b.isCircle;
}
}an[maxN], bn[maxN];

int findset(int x)
{
if (x == father[x]) return x;
return father[x] = findset(father[x]);
}
void Union(int x, int y)
{
x = findset(x); y = findset(y);
if (x == y)
{
isCircle[x] = 1;
return;
}
if (PT[x]>PT[y])
{
father[y] = x;
PT[x] += PT[y];
}
else
{
father[x] = y;
PT[y] += PT[x];
}
}

int main()
{
int t, ncase = 1;
scanf("%d", &t);
while (t--)
{
scanf("%d%d", &n, &m);
memset(isCircle, 0, sizeof(isCircle));
for (int i = 1; i