IOIT Final Round 2023-24 | Cntcrit

This was the problem page during the contest. Access the current page here.
Time limit: 0.6s
Memory limit: 256MB
Input:
Output:

Task

You are given an integer NN. Consider all the labeled undirected graphs with NN vertices. For each such graph, count the number of critical edges in it. Find the sum of the number of critical edges for all undirected graphs with NN vertices.

An edge (u,v)(u, v) is critical if by removing it, the number of connected components increases.

Since this number can be very large, print it modulo MM, where MM is a prime number.

Input data

The first line of the input will contain the numbers NN and MM.

Output data

Print a single integer, the sum of the number of critical edges for all undirected graphs with NN vertices.

Constraints and clarifications

  • 1N5 0001 \leq N \leq 5 \ 000
  • 2M109+92 \leq M \leq 10^{9} + 9, MM is prime.
# Points Constraints
1 11 1N61 \leq N \leq 6
2 53 1N1501 \leq N \leq 150
4 36 No additional constraints.

Example 1

stdin

6 2017

stdout

1254

Example 2

stdin

319 666013

stdout

385993

Contest info

Virtual contest

Start time: 1709307480000

Total duration: 169h22m0s

Status: Ended

Individual duration: 3h0m0s

Log in or sign up to be able to send submissions!