QOJ.ac

QOJ

时间限制: 0.5 s 内存限制: 256 MB 总分: 100

#13185. 国家灾难:双塔

统计

尽管印尼政府做出了努力,但该国仍经常遭受不受控制的森林火灾,这给当地居民及邻国带来了困扰。许多解决方案已被提出并实施(例如,在燃烧区域投放水弹),但随着时间的推移,新的热点地区总会不断出现。尽管如此,印尼总统因陀罗(Indra)并没有放弃解决这一问题。

印尼有两个火警瞭望塔,分别位于 $(x_1, y_1)$ 和 $(x_2, y_2)$,其中 $x_1 < x_2$ 且 $y_1 < y_2$。此外,全国各地散布着 $N$ 个热点。第 $i$ 个热点是一个圆,半径为 $r_i$,圆心位于 $(fx_i, fy_i)$。一个点 $(x, y)$ 如果满足以下所有条件,则被认为是安全的:

  1. $x_1 \le x \le x_2$
  2. $y_1 \le y \le y_2$
  3. 它不能严格位于任何燃烧区域内;换句话说,对于所有 $1 \le i \le N$,点 $(x, y)$ 到 $(fx_i, fy_i)$ 的距离应至少为 $r_i$。

两个瞭望塔的位置保证是安全的。当且仅当存在一条连接两个瞭望塔的安全路径时,两个瞭望塔才能正常通信。如果路径上的所有点都是安全的,则该路径被认为是安全的。注意,本题定义的“路径”是指任何连续且不一定为直线的线段。

你的任务是确定这两个瞭望塔是否能够正常通信。

输入格式

输入的第一行包含五个整数:$x_1, y_1, x_2, y_2, N$($-1,000,000 \le x_1 < x_2 \le 1,000,000$;$-1,000,000 \le y_1 < y_2 \le 1,000,000$;$0 \le N \le 1000$),表示两个瞭望塔的位置 $((x_1, y_1)$ 和 $(x_2, y_2))$ 以及热点的数量。接下来的 $N$ 行,每行包含三个整数:$fx_i, fy_i, r_i$($-1,000,000 \le fx_i, fy_i \le 1,000,000$;$1 \le r_i \le 2,000,000$),表示第 $i$ 个热点的中心位置 $((fx_i, fy_i))$ 及其燃烧区域的半径。保证没有两个热点位于相同的 $(fx_i, fy_i)$ 位置。

输出格式

输出包含一行,为 "YES" 或 "NO"(不含引号),表示两个瞭望塔是否能够正常通信。

样例

样例输入 1

-15 -10 15 10 5 
-20 7 9 
-2 3 6 
8 -3 4 
-1 -8 3 
-9 -1 3

样例输出 1

YES

样例输入 2

2 10 18 30 3 
10 20 5 
10 29 5 
10 11 5

样例输出 2

NO

样例输入 3

2 10 18 30 3 
10 20 5 
10 25 5 
10 10 5

样例输出 3

YES

说明

第一个样例的解释:上图展示了连接两个瞭望塔的一条安全路径。

第二个样例的解释:对于第二个样例,不存在可能的安全路径。

第三个样例的解释:对于第三个样例,下图展示了连接两个瞭望塔的安全路径的两个示例。注意,上图中 (10, 15) 处的点和下图中 (10, 30) 处的点是安全的。

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.