#abc284h. Ex - Count Unlabeled Graphs

Ex - Count Unlabeled Graphs

Score : 600600 points

问题描述

您需要通过以下步骤生成一个图形。

  • 选择一个包含 NN 个未标记顶点的简单无向图。
  • 在图中每个顶点处写入不大于 KK 的正整数。这里,不允许存在任何不在任何顶点上书写的不大于 KK 的正整数。

求能够得到的图形数量模 PP 后的结果。(其中,PP 是一个 质数。)

两个图形被认为是相同的,当且仅当可以为每个图形中的顶点标上标签 v1,v2,,vNv_1, v_2, \dots, v_N ,以满足以下条件:

  • 对于所有满足 1iN1 \leq i \leq Nii,两个图形中顶点 viv_i 上所写的数字相同。
  • 对于所有满足 1i<jN1 \leq i < j \leq Niijj,若其中一个图形中 viv_ivjv_j 之间有边,则另一个图形中 viv_ivjv_j 之间也必须有边;反之亦然。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are to generate a graph by the following procedure.

  • Choose a simple undirected graph with NN unlabeled vertices.
  • Write a positive integer at most KK in each vertex in the graph. Here, there must not be a positive integer at most KK that is not written in any vertex.

Find the number of possible graphs that can be obtained, modulo PP. (PP is a prime.)

Two graphs are considered the same if and only if one can label the vertices in each graph as v1,v2,,vNv_1, v_2, \dots, v_N to satisfy the following conditions.

  • For every ii such that 1iN1 \leq i \leq N, the numbers written in vertex viv_i in the two graphs are the same.
  • For every ii and jj such that 1i<jN1 \leq i \lt j \leq N, there is an edge between viv_i and vjv_j in one of the graphs if and only if there is an edge between viv_i and vjv_j in the other graph.

Constraints

  • 1KN301 \leq K \leq N \leq 30
  • 108P10910^8 \leq P \leq 10^9
  • PP is a prime.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN KK PP

Output

Print the answer.

Sample Input 1

3 1 998244353

Sample Output 1

4

The following four graphs satisfy the condition.

image

Sample Input 2

3 2 998244353

Sample Output 2

12

The following 1212 graphs satisfy the condition.

image2

Sample Input 3

5 5 998244353

Sample Output 3

1024

Sample Input 4

30 15 202300013

Sample Output 4

62712469

update @ 2024/3/10 11:54:50