Codeforces Round 340 (Div. 2)
C
Watering Flowers
Codeforces
1600
原题
← BD →
翻译中…

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.

翻译中…

Input

翻译中…

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.

翻译中…

Output

翻译中…

Print the minimum possible value $*r*_{1}^{2} + *r*_{2}^{2}$. Note, that in this problem optimal answer is always integer.

翻译中…

Note

翻译中…

The first sample is ($*r*_{1}^{2} = 5$, $*r*_{2}^{2} = 1$): image The second sample is ($*r*_{1}^{2} = 1$, $*r*_{2}^{2} = 32$): image

翻译中…

样例

Input #1
2 -1 0 5 3
0 2
5 2
Output #1
6
InputCopy OutputCopy
Input #2
4 0 0 5 0
9 4
8 3
-1 0
1 4
Output #2
33
InputCopy OutputCopy
题目信息
题号
617C
时间限制
2 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。