#P9030. [COCI 2022/2023 #1] Berilij

[COCI 2022/2023 #1] Berilij

Background

The little sheep Berilij was kidnapped by aliens. She needs to help the aliens solve a problem.

Problem Description

On the day of the COCI contest, the aliens plan to visit Earth with nn spaceships and give contestants generous rewards. Their spaceships are all perfect circles.

For safety reasons, they chose mm pairs of spaceships that must be in external contact when landing. The aliens have already determined the landing point coordinates of each spaceship, and Berilij's task is to determine the radius of each spaceship so that all spaceships can land safely.

As shown in the figure, neither the left pair nor the right pair of spaceships satisfies the external contact condition. Only the middle pair satisfies the external contact condition. In other words, “external contact” is defined as: two spaceships are in external contact if and only if the corresponding circles are externally tangent.

Spaceships are expensive to build, and their cost equals their area, so the aliens want the total cost to be as small as possible. Since the aliens are very advanced, their spaceships may overlap, and the diameter may also be 00.

If Berilij cannot solve this problem, the aliens will eat her. Please help the little sheep Berilij.

Input Format

The first line contains two integers n,mn,m, representing the number of alien spaceships and the number of pairs of spaceships that need to be in contact.

The next nn lines each contain two real numbers xi,yix_i,y_i, representing the coordinates of the landing point of the ii-th spaceship. The given coordinates are accurate to 10 digits after the decimal point.

The following mm lines contain two integers aia_i and bib_i, indicating that spaceship aia_i and spaceship bib_i must be in external contact after landing. The testdata guarantees that the unordered pairs (ai,bi)(a_i,b_i) are not repeated.

Output Format

If there is no solution, output one line: NE

Otherwise, output the first line: DA Then output nn lines, each containing the radius of a spaceship in a minimum-cost solution.

3 3
0.0000000000 0.0000000000
0.0000000000 2.0000000000
2.0000000000 0.0000000000
1 2
2 3
3 1
DA
0.585786
1.414214
1.414214
5 4
-0.4585133080 0.2893567973
9.9368007273 7.1806641913
-8.4621834970 -2.8309311865
0.0122121945 -2.8309311865
2.3991780589 -8.8626906628
2 1
3 2
4 3
5 1
DA
0.000000
12.472076
8.474396
0.000000
9.587824
5 5
0.0000000000 0.0000000000
1.0000000000 2.0000000000
2.0000000000 4.0000000000
3.0000000000 6.0000000000
4.0000000000 8.0000000000
1 2
2 3
3 4
4 5
5 1
NE

Hint

If the absolute or relative error of your answer is at most 10410^{-4}, it will be considered correct.

Subtask Score Special Property
11 1515 nn is odd and every spaceship is in contact with exactly two spaceships
22 2525 The testdata guarantees a solution exists
33 3030 For any pair of spaceships (a,b)(a,b), there exists exactly one spaceship sequence that starts at aa and ends at bb, and in this sequence every two adjacent spaceships are in contact with each other
44 4040 No special properties

Constraints: for 100%100\% of the testdata, 1n,m1051\leq n,m \leq 10^5, 104xi,yi104-10^4\leq x_i,y_i \leq 10^4, 1ai,bin1\leq a_i,b_i \leq n, and aibia_i \neq b_i.

The full score for this problem is 110 points.

Translated by ChatGPT 5