#P7138. [THUPC 2021 初赛] 非欧几何
[THUPC 2021 初赛] 非欧几何
Description
ustze likes geometry. He believes geometry is the easiest part of math contests. After conquering mathematics, ustze decided to bring his talent into computational geometry and compete with traditional Euclidean geometry.
As a defender of Euclidean geometry, Tinytree builds in 3D space a sphere with center at the origin and radius . The point with coordinates is called the North Pole, and obviously it lies on the sphere. Tinytree recalls that in Euclidean geometry, three points can uniquely determine a circle in space. Therefore, Tinytree chooses pairs of points on the sphere. For each pair, together with the North Pole, they determine a circle on the sphere. We guarantee that the radius of each such circle is strictly less than . Hence each circle divides the sphere into two parts of unequal area. We call the part with smaller area the interior of the circle, and the part with larger area the exterior of the circle. The interiors of these circles are protected by Tinytree, and their union forms the safe region.
As a fanatic of non-Euclidean geometry, ustze thinks that circles on a sphere are actually “straight lines”. He chooses pairs of points on the sphere. For each pair, together with the North Pole, they also determine a circle on the sphere. The radii of these circles are also strictly less than . The interiors of these circles are under ustze’s intimidation, and their union forms the dangerous region.
While Tinytree and ustze are confronting each other, a passerby named Kiana happens to be on the sphere. She is frightened by what she sees and starts to hide and move around on the sphere. Now Kiana has preliminarily chosen points on the sphere. She wants to know whether these points are in the safe region or the dangerous region so that she can decide where to run. Since Kiana cannot compute it herself, she hopes you can help her.
Input Format
The first line contains three positive integers and (, ), representing the number of point pairs chosen by Tinytree, the number of point pairs chosen by ustze, and the number of escape points chosen by Kiana.
The second line contains a positive integer (), representing the radius of the sphere.
The next lines: the -th line contains (, ). Here, are the - and -coordinates of the first point in Tinytree’s -th pair, and is + meaning the -coordinate of the first point is greater than , and - meaning the -coordinate is less than . If the -coordinate equals , then is chosen randomly between + and -. Similarly, are the - and -coordinates of the second point in the pair, and indicates the sign of its -coordinate, with the same meaning as .
The next lines: the -th line contains (, ), representing the coordinates of ustze’s -th point pair. The representation of points is the same as above.
The next lines: the -th line contains two real numbers (, ) and a character , representing Kiana’s -th escape point. The representation of points is the same as above.
The testdata guarantees validity, and there are no two identical points in the input. All real numbers are given to three digits after the decimal point. The minimum straight-line distance between any of Kiana’s escape points and the circumference of any given circle is at least .
Output Format
Output lines. Each line contains a string. If Kiana’s -th escape point is in the safe region, output Safe on the -th line. If it is not in the safe region and also not in the dangerous region, output Passer on the -th line. If it is not in the safe region but is in the dangerous region, output Goodbye (all outputs are without quotes).
2 2 4
3
2.571 0.514 + 2.571 -0.514 +
-2.571 0.514 + -2.571 -0.514 +
0.514 2.571 + -0.514 2.571 +
0.514 -2.571 + -0.514 -2.571 +
2.118 -2.118 -
1.051 1.051 +
-0.468 1.870 +
-1.870 -0.468 +
Passer
Safe
Goodbye
Safe
Hint
In 3D space, we can use an ordered real triple to describe the position of a point, where are called the -coordinate, -coordinate, and -coordinate of the point.
A sphere in 3D space with center at and radius refers to the set of all points satisfying . For two different points on this sphere, if they are not a pair of antipodal points (two points are antipodal if and only if the distance between them is ), then these two points and the center are not on the same line. These three points uniquely determine a plane. The intersection of this plane with the sphere is divided by the two points into two parts, and the length of the shorter part is called the distance between the two points on the sphere. If the two points are antipodal, then their distance is defined as . A circle on a sphere refers to the set of points on the sphere whose spherical distance to some point on the sphere equals a constant. It can be proven that any three different points on the sphere uniquely determine a circle on the sphere.
[Source]
From the preliminary round of the 2021 Tsinghua University Programming Contest and Collegiate Invitational (THUPC2021).
Resources such as editorials can be found at https://github.com/THUSAAC/THUPC2021-pre.
Translated by ChatGPT 5
京公网安备 11011102002149号