A10249 | Watering Flowers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
A flowerbed has many flowers and two fountains.
You can adjust the water pressure and set any values $r_{1}(r_{1}>=0)$ and $r_{2}(r_{2}>=0)$ , giving the distances at which the water is spread from the first and second fountain respectively. You have to set such $r_{1}$ and $r_{2}$ that all the flowers are watered, that is, for each flower, the distance between the flower and the first fountain doesn't exceed $r_{1}$ , or the distance to the second fountain doesn't exceed $r_{2}$ . It's OK if some flowers are watered by both fountains.
You need to decrease the amount of water you need, that is set such $r_{1}$ and $r_{2}$ that all the flowers are watered and the $r_{1}^{2}+r_{2}^{2}$ is minimum possible. Find this minimum value.
You can adjust the water pressure and set any values $r_{1}(r_{1}>=0)$ and $r_{2}(r_{2}>=0)$ , giving the distances at which the water is spread from the first and second fountain respectively. You have to set such $r_{1}$ and $r_{2}$ that all the flowers are watered, that is, for each flower, the distance between the flower and the first fountain doesn't exceed $r_{1}$ , or the distance to the second fountain doesn't exceed $r_{2}$ . It's OK if some flowers are watered by both fountains.
You need to decrease the amount of water you need, that is set such $r_{1}$ and $r_{2}$ that all the flowers are watered and the $r_{1}^{2}+r_{2}^{2}$ is minimum possible. Find this minimum value.
输入格式
The first line of the input contains integers $n$ , $x_{1}$ , $y_{1}$ , $x_{2}$ , $y_{2}$ ( $1<=n<=2000$ , $-10^{7}<=x_{1},y_{1},x_{2},y_{2}<=10^{7}$ ) — the number of flowers, the coordinates of the first and the second fountain.
Next follow $n$ lines. The $i$ -th of these lines contains integers $x_{i}$ and $y_{i}$ ( $-10^{7}<=x_{i},y_{i}<=10^{7}$ ) — the coordinates of the $i$ -th flower.
It is guaranteed that all $n+2$ points in the input are distinct.
Next follow $n$ lines. The $i$ -th of these lines contains integers $x_{i}$ and $y_{i}$ ( $-10^{7}<=x_{i},y_{i}<=10^{7}$ ) — the coordinates of the $i$ -th flower.
It is guaranteed that all $n+2$ points in the input are distinct.
输出格式
Print the minimum possible value $r_{1}^{2}+r_{2}^{2}$ . Note, that in this problem optimal answer is always integer.
输入输出样例
输入 #1
2 -1 0 5 3 0 2 5 2
输出 #1
6
输入 #2
4 0 0 5 0 9 4 8 3 -1 0 1 4
输出 #2
33
The first sample is ( $r_{1}^{2}=5$ , $r_{2}^{2}=1$ ):  The second sample is ( $r_{1}^{2}=1$ , $r_{2}^{2}=32$ ): 
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted