QOJ.ac

QOJ

実行時間制限: 16 s メモリ制限: 512 MB 満点: 100

#3165. 网格守护者

統計

Alice 拥有一个 $n \times m$ 的网格和一个 $2 \times 2$ 的方块。她想把这个方块放置在网格中。她必须确保方块与网格轴对齐,并恰好覆盖 4 个网格单元。

Bob 想要阻止 Alice 这样做。为此,他在网格的一些单元格中放置障碍物。在 Bob 放置障碍物后,网格中的所有 $2 \times 2$ 子网格都应至少包含一个障碍物。Bob 希望最小化他放置障碍物的网格单元数量。

请帮助 Bob 计算他以最少数量的障碍物阻止 Alice 放置方块的方法数。输出该数量对一个质数 $p$ 取模的结果。注意,答案不是最少障碍物的数量,而是 Bob 放置最少数量障碍物的方法总数。例如,如果 $n = m = 2$(即 $2 \times 2$ 网格),Bob 只需要放置 1 个障碍物,但有 4 种放置方法,因此这种情况下的答案是 4。

输入格式

输入包含一行,由三个空格分隔的整数 $n$ ($2 \le n \le 25$),$m$ ($2 \le m \le 10^3$) 和 $p$ ($10^8 \le p \le 10^9 + 7$,$p$ 是一个质数),其中 Alice 的网格大小为 $n \times m$,$p$ 是一个大质数模数。

输出格式

输出一个整数,表示 Bob 在 $n \times m$ 网格中放置最少数量的障碍物以阻止 Alice 放置 $2 \times 2$ 方块的方法数。由于这个数字可能非常大,请将其对 $p$ 取模后输出。

样例

样例输入 1

4 4 999999937

样例输出 1

79

样例输入 2

5 5 100000037

样例输出 2

1

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.