DMOPC '21 Contest 9 P6 - Shortest Paths

View as PDF

Submit solution


Points: 30 (partial)
Time limit: 2.5s
Memory limit: 256M

Author:
Problem types

Let the value of a connected undirected graph be the length of the shortest path from 1 to N. Compute the sum of the values of all connected simple graphs with N vertices and M edges of length 1 for each M \in [N - 1, R]. Since the answers may be very large, output them modulo the prime P.

Constraints

2 \le N \le 60

N - 1 \le R \le \frac{N(N - 1)}{2}

10^8 \le P \le 10^9

P is prime.

Subtask 1 [30%]

N, R \le 15

Subtask 2 [20%]

N, R \le 35

Subtask 3 [30%]

N \le 35

Subtask 4 [20%]

No additional constraints.

Input Specification

The first and only line contains 3 integers N, R, and P.

Output Specification

On a single line, output the desired values modulo P.

Sample Input 1

3 3 100000007

Sample Output 1

4 1

Explanation for Sample 1

There are three graphs with 3 nodes and 2 edges. One has a value of 2, and two have a value of 1. There is one graph with 3 nodes and 3 edges, and it has a value of 1.

Sample Input 2

4 6 100000007

Sample Output 2

26 20 7 1

Comments

There are no comments at the moment.