CF198E.Gripping Story

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

One day Qwerty the Ranger witnessed two transport ships collide with each other. As a result, all contents of their cargo holds scattered around the space. And now Qwerty wants to pick as many lost items as possible to sell them later.

The thing is, both ships had lots of new gravitational grippers, transported to sale. A gripper is a device that can be installed on a spaceship and than draw items in space to itself ("grip") and transport them to the ship's cargo hold.

Overall the crashed ships lost n gravitational grippers: the i-th gripper is located at a point with coordinates (x__i, y__i). Each gripper has two features — p__i (the power) and r__i (the action radius) and can grip any items with mass of no more than p__i at distance no more than r__i. A gripper itself is an item, too and it has its mass of m__i.

Qwerty's ship is located at point (x, y) and has an old magnetic gripper installed, its characteristics are p and r. There are no other grippers in the ship's cargo holds.

Find the largest number of grippers Qwerty can get hold of. As he picks the items, he can arbitrarily install any gripper in the cargo hold of the ship, including the gripper he has just picked. At any moment of time the ship can have only one active gripper installed. We consider all items and the Qwerty's ship immobile when the ranger picks the items, except for when the gripper moves an item — then the item moves to the cargo holds and the ship still remains immobile. We can assume that the ship's cargo holds have enough room for all grippers. Qwerty can use any gripper he finds or the initial gripper an arbitrary number of times.

某日,巡 Ranger Qwerty 目睹了两艘运输飞船相撞。结果,它们货舱中的所有货物散落在太空中。现在,Qwerty 希望尽可能多地拾取这些散落的物品,以便日后出售。

事实上,这两艘飞船均载有大量新型引力抓取器(gravitational gripper),用于销售。抓取器是一种可安装在飞船上的装置,能将太空中的物品“吸附”至自身,并将其运送至飞船货舱。

两艘失事飞船共遗失了 $ n $ 个引力抓取器:其中第 $ i $ 个抓取器位于坐标 $ (x_i,,y_i) $ 处。每个抓取器具有两个参数——$ p_i $(功率)与 $ r_i $(作用半径),它能够抓取质量不超过 $ p_i $、且距离不超过 $ r_i $ 的任意物品。抓取器本身也是一件物品,其质量为 $ m_i $。

Qwerty 的飞船位于点 $ (x,,y) $,船上已安装一个旧磁力抓取器,其参数为 $ p $ 和 $ r $。飞船货舱中无其他抓取器。

请计算 Qwerty 最多能获取多少个抓取器。他在拾取物品过程中,可任意将刚拾取到的抓取器(或任何已拥有的抓取器)安装至飞船货舱;但在任意时刻,飞船上仅能安装并启用一个抓取器。我们假设:当 Ranger 拾取物品时,所有物品及 Qwerty 的飞船均保持静止(抓取器移动物品的过程除外——此时物品被移入货舱,而飞船仍保持静止)。可假定飞船货舱空间足够容纳所有抓取器。Qwerty 可以无限次地使用他找到的任意抓取器,或初始配备的抓取器。

输入格式

The first line contains five integers x, y, p, r and n ( - 109 ≤ x, y ≤ 109, 1 ≤ p, r ≤ 109, 1 ≤ n ≤ 250000) — the ship's initial position, the initial gripper's features and the number of grippers that got into the space during the collision.

Next n lines contain the grippers' descriptions: the i-th line contains five integers x__i, y__i, m__i, p__i, r__i ( - 109 ≤ x__i, y__i ≤ 109, 1 ≤ m__i, p__i, r__i ≤ 109) — the i-th gripper's coordinates and features.

It is guaranteed that all grippers are located at different points. No gripper is located at the same point with Qwerty's ship.

第一行包含五个整数 xx、yy、pp、rr 和 nn(−109≤x,y≤109-10^9 \le x, y \le 10^9,1≤p,r≤1091 \le p, r \le 10^9,1≤n≤2500001 \le n \le 250000),分别表示飞船的初始位置、初始机械臂的属性,以及在碰撞过程中进入太空的机械臂数量。

接下来 nn 行描述各机械臂:第 ii 行包含五个整数 xix_i、yiy_i、mim_i、pip_i、rir_i(−109≤xi,yi≤109-10^9 \le x_i, y_i \le 10^9,1≤mi,pi,ri≤1091 \le m_i, p_i, r_i \le 10^9),表示第 ii 个机械臂的坐标及其属性。

保证所有机械臂均位于互不相同的点上,且没有任何机械臂与 Qwerty 的飞船位于同一点。

输出格式

Print a single number — the maximum number of grippers Qwerty can draw to his ship. You do not need to count the initial old magnet gripper.

输出一个整数——Qwerty 能为其飞船绘制的夹持器的最大数量。无需计算初始的旧磁铁夹持器。

输入输出样例

  • 输入#1

    0 0 5 10 5
    5 4 7 11 5
    -7 1 4 7 8
    0 2 13 5 6
    2 -3 9 3 4
    13 5 1 9 9

    输出#1

    3

说明/提示

In the first sample you should get the second gripper, then use the second gripper to get the first one, then use the first gripper to get the fourth one. You cannot get neither the third gripper as it is too heavy, nor the fifth one as it is too far away.

在第一个样例中,你应该先获取第二个夹持器,然后使用第二个夹持器获取第一个夹持器,再使用第一个夹持器获取第四个夹持器。你既无法获取第三个夹持器(因为它太重),也无法获取第五个夹持器(因为它离得太远)。

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

首页