NOIP2017 cheese (search, disjoint-set)

NOIP2017 cheese (disjoint-set, search)


Title Description

A conventional cheese as its height is h, its length and width We can be considered infinite, there are many intermediate cheese same radius of the spherical cavity. We can build in this cheese space coordinate system in the coordinate system, the lower surface of the cheese is z = 0, the upper surface of the cheese is z = h.
Now, the lower surface of the cheese has a little mouse Jerry, it knows the coordinates of cheese in all the empty center of the sphere is located. If two or voids tangent intersects Jerry went from one cavity to another cavity, in particular, if a hole or intersects the tangent to the lower surface, Jerry can run into the cavity from the lower surface of the cheese; if a hole or a tangential surface intersecting the upper, Jerry can run on the surface of the cheese from the cavity.
Located on the lower surface of the cheese Jerry wondered in without damaging the cheese case, the possibility of using existing voids on the surface of the cheese to go?
Space points P . 1 (X . 1 , Y . 1 , Z . 1 ), P 2 (X 2 , Y 2 , Z 2 ) from the following equation: d = $ \ sqrt {( x_1-x_2) ^ 2 + (y_1-y_2) ^ 2 + (z_1- z_2) ^ 2} $

Enter a description:

Each input file contains multiple sets of data. 
The first line of the input file, containing a positive integer T, represents the number of sets of data contained in the input file.
The next set of data is T, each data format is as follows:
The first line contains three positive integer n, h and r, to a space between two separate numbers, representing the height of the cavity in the cheese, and cheese empty radius.
The next n lines, each line contains three integers x, y, z, with a space between two separate numbers, showing hollow sphere center coordinates (x, y, z).

Output Description:

T output file contains the line, the answer corresponding group data T, if the i-th group of data, Jerry went from the lower surface of the upper surface,
 
the outputs "Yes", if not, outputs "No" (exclude quotation marks).
Example 1

Entry

copy
3
2 4 1
0 0 1
0 0 3
2 5 1
0 0 1
0 0 4
2 5 2
0 0 2
2 0 4

Export

copy
Yes
No
Yes

Remarks:

For 20% of the data, n = 1, 1 ≤ h , r ≤ 10,000, the absolute value of the coordinates of no greater than 10,000. 
Data for 40%, 1 ≤ n ≤ 8, 1 ≤ h, r ≤ 10,000, the absolute value of the coordinates of no greater than 10,000.
For 80% of data, 1 ≤ n ≤ 1,000, 1 ≤ h, r ≤ 10,000, the absolute value of the coordinates of no greater than 10,000.
To 100% of the data, 1 ≤ n ≤ 1,000, 1 ≤ h, r ≤ 1,000,000,000, T ≤ 20, an absolute value of the coordinate is not more than 1,000,000,000.

Guess you like

Origin www.cnblogs.com/phemiku/p/11771617.html