CF1055G.Jellyfish Nightmare

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Bob has put on some weight recently. In order to lose weight a bit, Bob has decided to swim regularly in the pool. However, the day before he went to the pool for the first time he had a weird dream. In this dream Bob was swimming along one of the pool's lanes, but also there were some jellyfish swimming around him. It's worth mentioning that jellyfish have always been one of Bob's deepest childhood fears.

Let us assume the following physical model for Bob's dream.

  1. The pool's lane is an area of the plane between lines x=0x=0 and x=wx=w. Bob is not allowed to swim outside of the lane, but he may touch its bounding lines if he wants.
  2. The jellyfish are very small, but in Bob's dream they are extremely swift. Each jellyfish has its area of activity around it. Those areas are circles of various radii, with the jellyfish sitting in their centers. The areas of activity of two jellyfish may overlap and one area of activity may even be fully contained within another one.
  3. Bob has a shape of a convex polygon.
  4. Unfortunately, Bob's excess weight has made him very clumsy, and as a result he can't rotate his body while swimming. So he swims in a parallel translation pattern. However at any given moment of time he can choose any direction of his movement.
  5. Whenever Bob swims into a jellyfish's activity area, it will immediately notice him and sting him very painfully. We assume that Bob has swum into the activity area if at some moment of time the intersection of his body with the jellyfish's activity area had a positive area (for example, if they only touch, the jellyfish does not notice Bob).
  6. Once a jellyfish stung Bob, it happily swims away and no longer poses any threat to Bob.

Bob wants to swim the lane to its end and get stung the least possible number of times. He will start swimming on the line y=−hy=-h, and finish on the line y=hy=h where h=1010h = 10^{10}.

鲍勃最近体重有所增加。为了减掉一些体重,他决定定期去泳池游泳。然而,在他第一次前往泳池的前一天晚上,他做了一个奇怪的梦。在梦中,鲍勃正沿着泳池的一条泳道游动,同时周围还有若干水母在游来游去。值得一提的是,水母一直是鲍勃童年时期最深的恐惧之一。

我们为鲍勃的梦境建立如下物理模型:

  1. 泳道是平面上介于直线 x=0x=0 与 x=wx=w 之间的区域。鲍勃不允许游出该泳道,但可以触碰其边界线(即 x=0x = 0 或 x=wx = w)。
  2. 水母体型极小,但在鲍勃的梦中它们行动极为迅捷。每只水母都拥有以其自身为中心、半径各异的一个活动区域;这些活动区域均为圆形。不同水母的活动区域可能相互重叠,甚至一个活动区域可能完全包含于另一个之中。
  3. 鲍勃的身体形状是一个凸多边形。
  4. 不幸的是,鲍勃因体重超标而变得十分笨拙,因此他在游泳过程中无法旋转身体,只能以平移方式移动。但在任意时刻,他都可以选择任意方向进行移动。
  5. 一旦鲍勃游入某只水母的活动区域,该水母便会立刻察觉并狠狠地蜇他。我们定义:若在某一时刻,鲍勃的身体与其所进入的水母活动区域的交集具有正面积(例如,仅相切则不视为进入),即认为鲍勃已游入该活动区域。
  6. 一旦某只水母蜇了鲍勃,它便会欣然游走,此后不再对鲍勃构成任何威胁。

鲍勃希望从泳道一端游至另一端,并尽可能少地被蜇。他将从直线 y=−hy=-h 处出发,最终抵达直线 y=hy=h 处,其中 h=1010h = 10^{10}。

输入格式

The first line contains two integers nn and ww (3≤n≤200,1≤w≤300003 \le n \le 200, 1 \le w \le 30000) — the number of vertices in the polygon that constitutes the Bob's shape and the width of the swimming pool lane.

Each of the next nn lines contains two integers xix_i and yiy_i (0≤xi≤w,0≤yi≤300000 \le x_i \le w, 0 \le y_i \le 30000) — the coordinates of corresponding vertex of the polygon. The vertices in the polygon are given in counterclockwise order. It is guaranteed that the given polygon is strictly convex.

The next line contains an only integer mm (0≤m≤2000 \le m \le 200) — the number of the jellyfish in the pool.

Each of the next mm lines contains three integers (xix_i, yiy_i, rir_i (0≤xi≤w,0≤yi≤30000,1≤ri≤300000 \le x_i \le w, 0 \le y_i \le 30000, 1 \le r_i \le 30000) — coordinates of the ii-th jellyfish in the pool and the radius of her activity. It is guaranteed, that no two jellyfish are located in the same point.

第一行包含两个整数 nn 和 ww(3≤n≤2003 \le n \le 200,1≤w≤300001 \le w \le 30000)—— 分别表示构成 Bob 形状的多边形的顶点数以及游泳池泳道的宽度。

接下来的 nn 行,每行包含两个整数 xix_i 和 yiy_i(0≤xi≤w0 \le x_i \le w,0≤yi≤300000 \le y_i \le 30000)—— 表示该多边形对应顶点的坐标。多边形的顶点按逆时针顺序给出。保证所给多边形是严格凸的。

下一行仅包含一个整数 mm(0≤m≤2000 \le m \le 200)—— 表示泳池中水母的数量。

接下来的 mm 行,每行包含三个整数 xix_i、yiy_i、rir_i(0≤xi≤w0 \le x_i \le w,0≤yi≤300000 \le y_i \le 30000,1≤ri≤300001 \le r_i \le 30000)—— 表示第 ii 只水母在泳池中的坐标及其活动半径。保证任意两只水母的位置均不相同。

输出格式

Output a single integer — the least possible number of jellyfish that will sting Bob.

输出一个整数——将刺伤鲍勃的水母的最少可能数量。

输入输出样例

  • 输入#1

    4 4
    0 0
    2 0
    2 2
    0 2
    3
    1 1 1
    3 5 1
    1 9 1

    输出#1

    0
  • 输入#2

    4 6
    0 0
    3 0
    3 3
    0 3
    3
    1 0 1
    4 2 2
    3 6 1

    输出#2

    2
  • 输入#3

    4 2
    0 0
    1 0
    1 1
    0 1
    2
    1 1 1
    1 3 1

    输出#3

    2

说明/提示

Visualization of the possible solutions to the first and the second sample test cases are below:

第一个和第二个样例测试用例的可能解的可视化如下:

输入解题思路,AI测评打分。不知道怎么写?

首页