DMOPC '21 Contest 7 P6 - Rainbow Subgraphs

View as PDF

Submit solution


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

Author:
Problem type

You are given positive integers N, M, and MOD.

Let V be the set of points (x,y) in the plane such that x and y are integers, y0, and N2x2+y2<(N+M)2. Let E be a set of undirected edges between elements of V, where (u,v)E if point u and point v are distance 1 apart.

Calculate the number of subgraphs of the graph G=(V,E), modulo MOD. That is, the number of pairs (V,E) such that VV, EE, and u,vV for all (u,v)E. Note that V and/or E are allowed to be empty or equal to V or E respectively.

Constraints

1N300

1M16

108MOD109

Subtask 1 [20%]

1N10

1M5

Subtask 2 [20%]

1N35

1M5

Subtask 3 [20%]

1N100

1M5

Subtask 4 [20%]

1N200

1M10

Subtask 5 [20%]

No additional constraints.

Input Specification

The first and only line of input contains three space-separated integers: N, M, and MOD.

Output Specification

Output the number of subgraphs modulo MOD.

Sample Input 1

Copy
1 1 998244352

Sample Output 1

Copy
89

Explanation for Sample 1

The graph G looks like the following:

Sample Input 2

Copy
2 2 998244352

Sample Output 2

Copy
41377047

Explanation for Sample 2

The graph G looks like the following:

Sample Input 3

Copy
31 4 159265358

Sample Output 3

Copy
54714600

Comments

There are no comments at the moment.