QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#12607. 朱大师与跳跃者

Statistics

考虑一个由方格组成的 $n \times m$ 矩形棋盘。Master Zhu 将一个跳跃者放置在位置 $(1, 1)$,即左上角的格子。

跳跃者可以从位置 $(x_1, y_1)$ 跳到位置 $(x_2, y_2)$,当且仅当正整数 $x_1, y_1, x_2, y_2$ 满足以下条件: $$(x_2 - x_1)^2 + (y_2 - y_1)^2 = 5,$$ $$x_2 > x_1,$$ $$y_2 > y_1.$$

不幸的是,棋盘上有一些障碍物。跳跃者不能进入有障碍物的格子。

Master Zhu 想要通过零次或多次跳跃将跳跃者移动到位置 $(n, m)$,即棋盘的右下角。请帮他计算跳跃者到达目标的方案数。由于答案可能非常大,请将其对 $110\,119$ 取模。

输入格式

第一行包含一个整数 $T$,表示测试用例的数量 ($1 \le T \le 540$)。

每个测试用例的第一行包含三个整数 $n, m$ 和 $r$:分别为棋盘的高度、宽度以及障碍物的数量 ($1 \le n, m \le 10^{18}, 0 \le r \le 100$)。

接下来 $r$ 行,每行包含两个整数 $x$ 和 $y$,表示一个障碍物的坐标 ($1 \le x \le n, 1 \le y \le m$)。保证所有给定的障碍物位置互不相同,且位置 $(1, 1)$ 没有障碍物。

输出格式

对于每个测试用例,输出答案对 $110\,119$ 取模的结果。

样例

输入 1

5
1 1 0
3 3 0
4 4 1
2 1
4 4 1
3 2
7 10 2
1 2
7 1

输出 1

1
0
2
1
5

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.