Hand in Hand
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?"
The first line contains a single positive integer T( T <= 100 ), indicating the number of datasets.
There are two graphs in each case, for each graph:
first line contains N( 1 <= N <= 10^4 ) and M indicating the number of kids and connections.
the next M lines each have two integers u and v indicating kid u and v are "hand in hand".
You can assume each kid only has two hands.
For each test case: output the case number as shown and "YES" if the two graph are isomorphism or "NO" otherwise.
Case #1: YES
Case #2: NO
- 有人能解释Php中奇怪的行为吗？ [关闭]
- PHP被称为“二进制安全”的功能是什么？ 这些“非二进制安全”函数向哪些库移除字符串？ 为什么？
- 创建List对象，老是报错The left-hand side of an assignment must be a variable？