A8635 | Gripping Story
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line contains five integers $x$ , $y$ , $p$ , $r$ and $n$ ( $-10^{9}<=x,y<=10^{9}$ , $1<=p,r<=10^{9}$ , $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}$ ( $-10^{9}<=x_{i},y_{i}<=10^{9}$ , $1<=m_{i},p_{i},r_{i}<=10^{9}$ ) — 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.
Next $n$ lines contain the grippers' descriptions: the $i$ -th line contains five integers $x_{i}$ , $y_{i}$ , $m_{i}$ , $p_{i}$ , $r_{i}$ ( $-10^{9}<=x_{i},y_{i}<=10^{9}$ , $1<=m_{i},p_{i},r_{i}<=10^{9}$ ) — 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.
输出格式
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.
输入输出样例
输入 #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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted