QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#17366. Counting Generalized Series-Parallel Graphs

統計

A labeled undirected graph is defined as a simple generalized series-parallel graph if and only if:

  1. The graph is connected;
  2. The graph contains no multiple edges or self-loops;
  3. For any $4$ nodes, there do not exist $6$ paths that are pairwise vertex-disjoint (except at endpoints) connecting every pair of these $4$ nodes.

Let $f(i, j)$ denote the number of simple generalized series-parallel graphs with $i$ vertices and $j$ edges.

Given $n, m, p$, you need to calculate $f(i, j) \bmod p$ for all $1 \leq i \leq n$ and $1 \leq j \leq m$.

Input

A single line containing three positive integers $n, m, p$.

Output

Output $n$ lines, each containing $m$ integers, where the $j$-th integer in the $i$-th line represents the value of $f(i, j) \bmod p$.

Examples

Input 1

5 10 998244353

Output 1

0 0 0 0 0 0 0 0 0 0 
1 0 0 0 0 0 0 0 0 0 
0 3 1 0 0 0 0 0 0 0 
0 0 16 15 6 0 0 0 0 0 
0 0 0 125 222 205 70 0 0 0

Input 2

See additional files.

Constraints

For all test cases, it is guaranteed that:

  • $1 \le n, m \le 50$;
  • $10^8 \le p \le 10^9+7$, and $p$ is a prime number.

This problem uses bundled testing.

  • Subtask 1 (8 points): $n \le 8$, $m \le 10$.
  • Subtask 2 (12 points): $n \le 10$, $m \le 20$.
  • Subtask 3 (12 points): $n \le 11$, $m \le 20$.
  • Subtask 4 (32 points): $n, m \le 25$.
  • Subtask 5 (36 points): No additional constraints.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1562EditorialOpen题解ucup-team78702026-04-17 22:47:03View
#1564Editorial OpenNew Editorial for Problem #17366ChiFAN2026-04-17 22:42:28 Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.