luogu#P6998. [NEERC2013] Cactus Automorphisms
[NEERC2013] Cactus Automorphisms
题目描述
NEERC had featured a number of problems in previous years about cactuses -- connected undirected graphs in which every edge belongs to at most one simple cycle. Intuitively, cactus is a generalization of a tree where some cycles are allowed.
In , the first year where problems about cactuses had appeared, the problem was called simply Cactus
. In it was Cactus Reloaded
and in it was called Cactus Revolution
. An example of cactus from NEERC problem is given on the picture below.
The challenge that judges face when preparing test cases for those problems is that some wrong solutions may depend on the numbering of vertices in the input file. So, for the most interesting test cases judges typically include several inputs with the same graph, but having a different numbering of vertices. However, some graphs are so regular that the graph remains the same even if you renumber its vertices. Judges need some metric about the graph that tells how regular the given graph is in order to make an objective decision about the number of test cases that need to be created for this graph.
The metric you have to compute is the number of graph automorphisms. Given an undirected graph , where is a set of vertices and is a set of edges, where each edge is a set of two distinct vertices graph automorphism is a bijection from onto , such that for each pair of vertices and that are connected by an edge (so the following condition holds: .
Each graph has at least one automorphism (one where is an identity function) and may have up to ! automorphisms for a graph with vertices. Because the number of automorphisms may be a very big number, the answer must be presented as a prime factorization where are prime numbers in ascending order .
输入格式
The first line of the input file contains two integer numbers and . Here is the number of vertices in the graph. Vertices are numbered from to . Edges of the graph are represented by a set of edge-distinct paths, where is the number of such paths.
Each of the following lines contains a path in the graph. A path starts with an integer number followed by integers from to . These integers represent vertices of a path. Adjacent vertices in a path are distinct. Path can go to the same vertex multiple times, but every edge is traversed exactly once in the whole input file. There are no multiedges in the graph (there is at most one edge between any two vertices).
The graph in the input file is a cactus.
输出格式
On the first line of the output file write number -- the number of prime factors in the factorization of the number of graph automorphisms. Write if the number of graph automorphisms is . On the following lines write prime numbers and their powers separated by a space. Prime numbers must be given in ascending order.
题目大意
- 仙人掌是满足如下条件的无向简单连通图:每条边被包含于至多一个简单环中。
- 设有无向图 。称双射 是 的自同构,当且仅当 ,都有 。称两个自同构 相同,当且仅当 均有 。
- 给定有 个节点的仙人掌,求它的不同的自同构数。由于结果可能很大,你需要输出它的质因子分解的结果。
- 输入仙人掌的方式为:给定 条路径,这些路径所覆盖的边即为仙人掌的全部边。保证这些路径不会重复经过一条边两次,且输入的图是仙人掌。
- 。
15 3
9 1 2 3 4 5 6 7 8 3
7 2 9 10 11 12 13 10
5 2 14 9 15 10
1
2 2
2 1
2 1 2
1
2 1
15 7
3 1 2 3
3 4 2 5
3 6 2 7
3 8 2 9
3 10 2 11
3 12 2 13
3 14 2 15
6
2 11
3 5
5 2
7 2
11 1
13 1
提示
Time limit: 5 s, Memory limit: 256 MB.