链接:https://www.nowcoder.com/acm/contest/139/D
来源:牛客网
Two undirected simple graphs and where are isomorphic when there exists a bijection on V satisfying if and only if {x, y} ∈ E2.
Given two graphs and , count the number of graphs satisfying the following condition:
* .
* G1 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, m1 and m2 where |E1| = m1 and |E2| = m2. The i-th of the following m1 lines contains 2 integers ai and bi which denote {ai, bi} ∈ E1. The i-th of the last m2 lines contains 2 integers ai and bi which denote {ai, bi} ∈ E2.
For each test case, print an integer which denotes the result.
示例1
复制
3 1 2 1 3 1 2 2 3 4 2 3 1 2 1 3 4 1 4 2 4 3
复制
2 3
* 1 ≤ n ≤ 8 * * 1 ≤ ai, bi ≤ n * The number of test cases does not exceed 50.
题意:
n个点,m1条边的图E1,n个点,m2条边的图E2。求图E2有多少子图跟图E1同构。
题解:
用STL的全排列函数next_permutation()枚举映射。对于每一种映射枚举每一条边判断合法性。
总情况数要除以图E1的自同构数去重。
//Sinhaeng Hhjian
#include
#include
#include