CF617C.Watering Flowers
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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_12 + _r_22 is minimum possible. Find this minimum value.
一个花坛中有很多花朵和两个喷泉。
你可以调节水压,为第一个和第二个喷泉分别设定任意非负值 r1(r1≥0)和 r2(r2≥0),表示水从对应喷泉喷洒出的最大距离。你需要选定这样的 r1 和 r2,使得所有花朵都被浇灌到,即:对每一朵花,它到第一个喷泉的距离不超过 r1,或者它到第二个喷泉的距离不超过 r2。允许某些花朵同时被两个喷泉浇灌。
你需要最小化用水量,即选定满足上述条件的 r1 和 r2,使得 r12+r22 尽可能小。求该最小值。
输入格式
The first line of the input contains integers n, _x_1, _y_1, _x_2, _y_2 (1 ≤ n ≤ 2000, - 107 ≤ _x_1, _y_1, _x_2, _y_2 ≤ 107) — 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 ( - 107 ≤ x__i, y__i ≤ 107) — the coordinates of the i-th flower.
It is guaranteed that all n + 2 points in the input are distinct.
输入的第一行包含整数 n、x1、y1、x2、y2(1 ≤ n ≤ 2000,−107 ≤ x1, y1, x2, y2 ≤ 107)——分别表示花的数量,以及第一座和第二座喷泉的坐标。
接下来是 n 行。其中第 i 行包含整数 xi 和 yi(−107 ≤ xi, yi ≤ 107)——表示第 i 朵花的坐标。
保证输入中的全部 n+2 个点互不相同。
输出格式
Print the minimum possible value _r_12 + _r_22. Note, that in this problem optimal answer is always integer.
输出最小可能的值 r12+r22。注意,在本题中,最优解始终为整数。
输入输出样例
输入#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_12 = 5, _r_22 = 1):
The second sample is (_r_12 = 1, _r_22 = 32): 
第一个样例是(r12=5,r22=1): 
第二个样例是(r12=1,r22=32): 
输入解题思路,AI测评打分。不知道怎么写?