链接:
来源:牛客网 Two undirected simple graphs and where are isomorphic when there exists a bijection on V satisfying if and only if {x, y} ∈ E 2. Given two graphs and , count the number of graphs satisfying the following condition: * . * G 1 and G are isomorphic.
输入描述:
The input consists of several test cases and is terminated by end-of-file. The first line of each test case contains three integers n, m
1
and m
2
where |E
1
| = m
1
and |E
2
| = m
2
. The i-th of the following m
1
lines contains 2 integers a
i
and b
i
which denote {a
i
, b
i
} ∈ E
1
. The i-th of the last m
2
lines contains 2 integers a
i
and b
i
which denote {a
i
, b
i
} ∈ E
2
.
输出描述:
For each test case, print an integer which denotes the result.
示例1
输入
3 1 21 31 22 34 2 31 21 34 14 24 3
输出
23
备注:
* 1 ≤ n ≤ 8 *
* 1 ≤ a
i
, b
i
≤ n * The number of test cases does not exceed 50. 求图G1有多少个子图和图G2是同构图 枚举图G1的全排列子图,然后判断每一个子图是否和图G2是同构图 判断原理: 同构要求边,点以及点的结构都相同。 我们先存好图G1中每种边点结构的关系,用一个vis数组存下每条边 然后在全排列判断每个子图的时候判断这个子图是否和图G2同构,同构就用个set保存下这种情况(每种情况用散列哈希求出一个独一无二的值) 最后set的size就是结果
#include