#P1158. [NOIP 2010 普及组] 导弹拦截

    ID: 158 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>模拟2010NOIp 普及组枚举,暴力排序

[NOIP 2010 普及组] 导弹拦截

Description

After 1111 years of preparation, a certain country has developed a new missile interception system. Any missile whose distance to the system does not exceed its working radius can be successfully intercepted. When the working radius is 00, it can intercept missiles that are exactly at the same position as the system. However, the system has a limitation: each set of the system can have its working radius set only once per day. The usage cost for that day is the sum of the squares of the working radii of all systems.

One day, radar detected incoming enemy missiles. Since the system is still in the trial phase, only two systems are deployed. If the requirement is to intercept all missiles, compute the minimum usage cost for that day.

Input Format

The first line contains 44 integers x1,y1,x2,y2x_1, y_1, x_2, y_2, separated by a single space, indicating that the coordinates of the two missile interception systems are (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2). The second line contains 11 integer NN, the number of missiles. The next NN lines each contain two integers x,yx, y, separated by a single space, indicating the coordinates (x,y)(x, y) of a missile. Different missiles may share the same coordinates.

Output Format

A single integer, the minimum usage cost for that day.

0 0 10 0
2
-3 3
10 0
18
0 0 6 0
5
-4 -2
-2 3
4 0
6 -2
9 1
30

Hint

  • The square of the distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is (x1x2)2+(y1y2)2(x_1-x_2)^2+(y_1-y_2)^2.
  • The sum of the squares of the two working radii r1,r2r_1, r_2 means squaring them separately and then summing, i.e., r12+r22r_1^2+r_2^2.

Explanation for Sample 11: To intercept all missiles with minimum usage cost, the squares of the two systems’ working radii are 1818 and 00.

Explanation for Sample 22: The positions of the interception systems and the missiles are shown below. To intercept all missiles with minimum usage cost, the squares of the two systems’ working radii are 2020 and 1010.

Constraints:

  • For 10%10\% of the testdata, N=1N=1.
  • For 20%20\% of the testdata, 1N21\le N\le 2.
  • For 40%40\% of the testdata, 1N1001\le N\le 100.
  • For 70%70\% of the testdata, 1N10001\le N\le 1000.
  • For 100%100\% of the testdata, 1N1051\le N\le 10^5, and the absolute values of all coordinate components do not exceed 10001000.

NOIP 2010 Junior, Problem 3.

Translated by ChatGPT 5