QOJ.ac

QOJ

时间限制: 10 s 内存限制: 512 MB 总分: 100

#1179. 污染

统计

第三次世界大战爆发了!在短时间内,世界各地发生了核爆炸,爆炸污染了大片土地。放射性污染消灭了大量的动物种群,一些物种已经灭绝,而另一些则濒临灭绝。

对于一些濒危物种,我们观察到了一对该物种的动物。我们想知道这两只动物是否能够安全会合。使这个问题变得困难的原因在于,每个物种只能在特定的纬度范围内生存。

我们将世界建模为一个具有标准笛卡尔坐标的平面。$n$ 次核爆炸中每一次的污染区域都是一个以 $(c_x, c_y)$ 为圆心、半径为 $r$ 的圆。任何物种都无法在距离 $(c_x, c_y)$ 小于或等于 $r$ 的地方生存。各次爆炸的污染区域是两两不相交的(在同一个地方重复污染是一种浪费!)。

给定 $q$ 个查询,每个查询的形式为 $(p_x, p_y, q_x, q_y, y_{min}, y_{max})$,其中 $(p_x, p_y)$ 和 $(q_x, q_y)$ 是同一物种两只动物的坐标,$y_{min}$ 和 $y_{max}$ 定义了该物种可以生存的纬度范围。你需要确定是否可能从点 $(p_x, p_y)$ 到达点 $(q_x, q_y)$,同时避开污染区域,并且仅经过满足 $y_{min} \le y \le y_{max}$ 的点 $(x, y)$。你可以假设点 $(p_x, p_y)$ 和 $(q_x, q_y)$ 不在任何污染区域内。

输入格式

输入的第一行包含两个整数 $n, q$ ($1 \le n, q \le 10^6$),分别表示爆炸次数和查询次数。

接下来的 $n$ 行包含爆炸的描述。每个描述由三个整数 $c_x, c_y, r$ ($-10^9 \le c_x, c_y \le 10^9, 1 \le r \le 10^9$) 组成,表示爆炸污染区域的圆心坐标和半径。请记住,这些区域是两两不相交的。

随后的 $q$ 行包含关于动物的查询。每个查询由六个整数 $p_x, p_y, q_x, q_y, y_{min}, y_{max}$ ($-10^9 \le p_x, p_y, q_x, q_y, y_{min}, y_{max} \le 10^9, y_{min} \le p_y, q_y \le y_{max}$) 组成,含义如上所述。

输出格式

对于每个查询,如果这对动物可以安全会合,则在单独的一行中输出 “YES”,否则输出 “NO”。

样例

输入 1

3 3
3 3 2
7 7 3
12 5 2
1 4 14 4 2 6
1 4 14 4 4 7
1 4 14 4 3 9

输出 1

YES
NO
YES

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.