#P15999. [ICPC 2020 NAC] Grid Guardian
[ICPC 2020 NAC] Grid Guardian
题目描述
Alice has an grid and a block. She would like to place her block in the grid. She must place it so that the block is axis-aligned and covers exactly 4 grid cells.
Bob wants to prevent Alice from doing that. To do this, he places obstacles in some of the grid cells. After Bob places his obstacles, all subgrids of the grid should contain at least one obstacle. Bob wants to minimize the number of grid cells where he places obstacles.
Help Bob count the number of ways he can place the minimum number obstacles to prevent Alice from placing her block. Output this number modulo a prime number . Note that the answer is not the minimum number of obstacles, but rather the count of the number of ways Bob can place the minimum number of obstacles. For example, if for a grid, Bob only has to place 1 obstacle, but there are 4 ways to place it, so the answer in this case is 4.
输入格式
The single line of input contains three space-separated integers (), () and (, is a prime number), where Alice’s grid is of size , and is a large prime modulus.
输出格式
Output a single integer, which is the number of ways Bob can place the minimum number of obstacles in the grid to prevent Alice from placing her block. Since this may be very large, output it modulo .
4 4 999999937
79
5 5 100000037
1