#P11174. 「CMOI R1」Looking For Edge Of Ground/City Planning
「CMOI R1」Looking For Edge Of Ground/City Planning
Background
How to count simple labeled undirected connected graphs on vertices?$\small\color{white}/42^{\text{nd}}\text{Problem by ArCu}.$
There is an obviously wrong method: enumerate a tree, then add edges on it.
You need to compute the sum of squares of the number of times each graph is counted.
Problem Description
Given a positive integer .
At first, chooses a labeled undirected unrooted tree with vertices, and colors the edges on the tree white. Then he adds any number of edges to this tree, with the following requirements:
- The newly added edges are black undirected edges.
- After adding edges, if you ignore the colors, the resulting graph is a simple graph.
Next, puts all possible results into a set .
Obviously, this way of counting connected graphs will count the same graph many times, so defines as follows: in , there are graphs whose underlying graphs (ignoring edge colors) are the same as (two graphs are the same means for any edge , ).
( means summing over all possible graphs .) Obviously,
So you need to compute
Output the answer modulo . Unfortunately, for some reasons, the modulus cannot be .
Input Format
One line containing one positive integer .
Output Format
One line containing one integer, the answer you computed.
3
12
4
812
5
223440
107
404390093
Hint
The set contains the following graphs (an edge weight of means a white edge, and means a black edge; a vertex label like means this is vertex of graph ):

There are connected graphs on vertices:

Ignoring colors,
- The ones that are the same as are .
- The ones that are the same as are .
- The ones that are the same as are .
- The ones that are the same as are .
So the answer is .
This problem uses bundled testdata.
Translated by ChatGPT 5