#P10533. [Opoi 2024] 热核武器

[Opoi 2024] 热核武器

Background

The Flea Kingdom and the Cricket Kingdom are fighting fiercely.

level

The above is a tactical nuclear graphics card and is not related to the problem.

Problem Description

The territory of the Flea Kingdom can be viewed as a 2D Cartesian coordinate system.

The Flea Kingdom has N+1N+1 cities. One city is the capital, located at (0,0)(0,0). The other NN cities are ordinary cities. Assume the capital is city 00, and the other cities are numbered from 11 to NN. For each ordinary city ii, it is located at (xi,yi)(x_i,y_i).

Due to limited financial resources, for each city ii that is not the capital, it will choose a city jj to build a bidirectional road. Let dis(x,y)dis(x,y) be the Euclidean distance between cities xx and yy. Then for each city ii that is not the capital, the corresponding jj is the point that minimizes dis(i,j)dis(i,j) among all points satisfying dis(j,0)dis(i,0)dis(j,0) \le dis(i,0) and jij \ne i. If there are multiple valid jj, choose the one with the smallest index.

Define the γ\gamma value of a city as (the minimum number of roads needed to travel from this city to the capital) +1+1. If the capital cannot be reached, set the γ\gamma value to 00.

The Cricket Kingdom is going to carry out a tactical nuclear graphics card strike on the Flea Kingdom. This operation is divided into two groups: the Lorentz Group and the Ampere Group. Each group will strike some of the cities, and the two groups must strike each city in the Flea Kingdom exactly once.

For these two groups, fame is the most important, and the Cricket Kingdom’s evaluation standard is the sum of the γ\gamma values of the cities struck in this operation. So you need to determine whether there exists a partition such that the sums of γ\gamma values of the cities struck by the Lorentz Group and the Ampere Group are equal. If yes, output Yes, otherwise output No.

Input Format

The first line contains an integer NN, representing the number of ordinary cities in the Flea Kingdom.

The next NN lines (lines 22 to N+1N+1): the (i+1)(i+1)-th line contains two integers, representing the coordinates (xi,yi)(x_i,y_i) of city ii.

Output Format

Output one string in a single line, Yes or No, indicating whether there exists a way to make the sums of γ\gamma values of the cities struck by the Lorentz Group and the Ampere Group equal.

4
-1 -1
1 0
1 -2
-2 2
Yes

Hint

Sample Explanation

This figure looks like this:

For C1C_1: both C0C_0 and C2C_2 satisfy dis(j,C0)dis(C1,C0)dis(j,C_0) \le dis(C_1,C_0), but C0C_0 is closer to C1C_1, so add the edge (C1,C0)(C_1,C_0).

For C2C_2: only C0C_0 satisfies dis(j,C0)dis(C2,C0)dis(j,C_0) \le dis(C_2,C_0), so add the edge (C2,C0)(C_2,C_0).

For C3C_3: the three points C0C_0, C1C_1, and C2C_2 satisfy dis(j,C0)dis(C3,C0)dis(j,C_0) \le dis(C_3,C_0), but C2C_2 is closest to C3C_3, so add the edge (C3,C2)(C_3,C_2). Note that this is because when considering C3C_3, the optimal point is C2C_2, so C3C_3 builds a road to C2C_2, which is completely independent of the road (C2,C0)(C_2,C_0).

For C4C_4: all other points satisfy dis(j,C0)dis(C4,C0)dis(j,C_0) \le dis(C_4,C_0), but C0C_0 is closest to C4C_4, so add the edge (C4,C0)(C_4,C_0).

We obtain the following table:

City Index γ\gamma Value
C0C_0 11
C1C_1 22
C2C_2
C3C_3 33
C4C_4 22

So assign C0,C1,C2C_0,C_1,C_2 to the Lorentz Group, and assign C3,C4C_3,C_4 to the Ampere Group.

Constraints

1N5001 \le N \le 500, 106xi,yi106-10^6 \le x_i,y_i \le 10^6.

Special Note

Since the output of this problem is only Yes or No, this problem uses the minimum-score judging method, i.e., the minimum score among all test points is taken as the final result.

Translated by ChatGPT 5