QOJ.ac

QOJ

時間限制: 3 s 記憶體限制: 1024 MB 總分: 100

#4747. 蹦床

统计

Little Square 开始在学校体育馆的蹦床上跳跃。体育馆内有 $R \times C$ 个蹦床,排列成一个 $R$ 行 $C$ 列的矩形网格。每个蹦床要么是绿色的,要么是蓝色的。共有 $N$ 个绿色蹦床。令 $(i, j)$ 表示第 $i$ 行第 $j$ 列的蹦床。行号从 $1$ 到 $R$,列号从 $1$ 到 $C$。

Little Square 的老师要求他练习 $T$ 套体操动作。第 $i$ 套动作遵循以下规则:

  • 动作从蹦床 $(x_i^{\text{start}}, y_i^{\text{start}})$ 开始。
  • 动作在蹦床 $(x_i^{\text{stop}}, y_i^{\text{stop}})$ 结束。
  • 如果 Little Square 跳到了位置 $(i, j)$ 的绿色蹦床上,那么他可以前往 $(i+1, j)$ 或 $(i, j+1)$,前提是这些位置没有超出网格范围。
  • 如果 Little Square 跳到了位置 $(i, j)$ 的蓝色蹦床上,那么他可以前往 $(i, j+1)$,前提是该位置没有超出网格范围。

Little Square 想知道,对于每一套动作,是否有可能完成老师的要求。

输入格式

第一行包含 $R, C$ 和 $N$。接下来的 $N$ 行包含绿色蹦床的位置。如果某一行包含整数 $a, b$,则表示在位置 $(a, b)$ 有一个绿色蹦床。 下一行包含 $T$。接下来的 $T$ 行包含体操动作的描述。第 $i$ 行包含 $x_i^{\text{start}}, y_i^{\text{start}}, x_i^{\text{stop}}, y_i^{\text{stop}}$。

输出格式

输出 $T$ 行。第 $i$ 行应包含 Yes(如果可以完成第 $i$ 套动作)或 No(如果不能)。

数据范围

  • $1 \le R, C \le 1.000.000.000$
  • $1 \le N, T \le 200.000$
  • $1 \le x_i^{\text{start}}, x_i^{\text{stop}} \le R$
  • $1 \le y_i^{\text{start}}, y_i^{\text{stop}} \le C$
  • 绿色蹦床的坐标互不相同。

子任务

  • 子任务 1(23 分):$1 \le R, C, T \le 200$
  • 子任务 2(20 分):$1 \le R, C \le 2.500$,$1 \le T \le 4.000$
  • 子任务 3(11 分):$x_i^{\text{stop}} - x_i^{\text{start}} = 1$
  • 子任务 4(19 分):$1 \le T, N \le 5.000$
  • 子任务 5(27 分):无额外限制。

样例

输入 1

4 5 2
2 2
3 4
3
2 1 4 5
1 2 1 4
2 3 4 4

输出 1

Yes
Yes
No

说明

蹦床的放置方式如下:

在第一套动作中,Little Square 可以走以下路线:$(2, 1) \to (2, 2) \to (3, 2) \to (3, 3) \to (3, 4) \to (4, 4) \to (4, 5)$。

在第二套动作中,Little Square 可以走以下路线:$(1, 2) \to (1, 3) \to (1, 4)$。

第三套动作无法完成。不存在从 $(2, 3)$ 到 $(4, 4)$ 且符合 Little Square 老师规则的路线。

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.