luogu#P4727. [HNOI2009] 图的同构计数

    ID: 3709 远端评测题 2000ms 125MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学2009各省省选湖南群论置换Pólya 定理逆元

[HNOI2009] 图的同构计数

Background

When students run into a hard problem, they often say, “How can this be done? Isn’t this an NP problem?”, or “You can only search; this has already been proved to be an NP problem.” However, you should know that what most people call an NP problem in such cases actually refers to an NPC problem. Many people have not truly understood the two basic concepts: NP problems and NPC problems. In fact, an NP problem is not the kind of problem that “can only be solved by searching”; NPC problems are.

Long ago, there was an old legend: there is a famous question, namely whether PP equals NPNP. In the legend, whoever proves or disproves this statement will obtain happiness. Here, PP refers to the set of problems that can be solved in polynomial time. NPNP refers to the set of problems whose solutions can be verified in polynomial time. Clearly, PP is a subset of NPNP, because any problem solvable in polynomial time must also be verifiable in polynomial time.

So far, no one has obtained happiness because of this statement. However, there is a general trend: people commonly believe that P=NPP=NP does not hold. That is, most people believe that there exists at least one NP problem that cannot have a polynomial-time algorithm. People are so convinced that PNPP \neq NP for a reason: during the study of NP problems, researchers found a very special class of NP problems called NP-complete problems, i.e., the so-called NPC problems. It is precisely because NPC problems exist that people believe PNPP \neq NP.

After the concept of NPC was proposed, almost all “natural” hard problems were eventually proved to be NPC problems, with only three exceptions:

  • Linear programming;
  • Graph isomorphism;
  • Primality testing and integer factorization.

Problem Description

After learning the above, Xiaoxue felt that directly challenging the ultimate problem was still quite difficult, so he decided to start with simpler problems. Specifically, he became very interested in the graph isomorphism problem. Graph AA and graph BB are considered isomorphic if, after relabeling the vertices of graph AA in some way, the vertex set and edge set of AA correspond exactly one-to-one with those of BB.

Xiaoxue is now focused on how to determine whether two graphs are isomorphic. At the same time, he also wants to know how many pairwise non-isomorphic graphs with NN vertices there are. It is well known that a simple graph with NN vertices has at most N×(N1)/2N\times(N-1)/2 edges, so there are 2N×(N1)/22^{N\times(N-1)/2} possible graphs with NN vertices. Clearly, many of these graphs are isomorphic. What Xiaoxue wants to know is: if we count isomorphic graphs as one, how many different graphs are there? He threw this task to you—solve it quickly before he figures it out!

Input Format

The input contains a non-negative integer NN, representing the number of vertices of the graph, and 0N600 \leq N \leq 60.

Output Format

Output one integer, representing the number of graphs with NN vertices that are non-isomorphic under isomorphism. Since the answer may be very large, output the final result mod 997\bmod ~ 997 (997997 is a prime).

1
1
2
2
3
4
5
34
9
493

Hint

For 40%40\% of the testdata, N20N \le 20.
For 100%100\% of the testdata, 0N600 \le N \le 60.

Translated by ChatGPT 5