#P3993. [BJOI2017] 同构
[BJOI2017] 同构
Description
You have vertices. You may add undirected edges between these vertices, with at most one edge per pair and no self-loops. What is the maximum number of edges you can add?
The obvious answer is edges. Therefore, there is an additional constraint: the graph must not have a nontrivial automorphism.
A graph has a nontrivial automorphism if there exists a permutation of such that for all vertices , there is an edge between and if and only if there is an edge between and , and this permutation is nontrivial, i.e., there exists a vertex with .
For example, for the 5-vertex graph , the mapping , , , , is a nontrivial automorphism of this graph.
You need to answer: among simple undirected graphs on vertices that have no nontrivial automorphism, what is the maximum number of edges? If no such graph on vertices exists, output -1; otherwise, output the answer modulo .
Input Format
This problem contains multiple test cases.
A single line with a positive integer , the number of test cases.
For each test case:
A single positive integer , the number of vertices.
Output Format
For each test case:
Output a single integer, the answer modulo . If no graph on vertices satisfies the condition, output -1.
6
1
2
3
4
5
6
0
-1
-1
-1
-1
9
Hint
| Test point | Constraints |
|---|---|
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号