QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#4111. Ordinary Dice

Estadísticas

This is an ordinary die. It is a homogeneous convex polyhedron with $n$ vertices and $f$ faces. Each face is a convex polygon, and no two faces are coplanar. When this die is thrown into the air, it does not bounce upon landing (this is an idealized scenario). You want to know the probability of each face landing on the ground. The probability of each face landing can be calculated as follows: Let $O$ be the center of mass of the die. Construct a unit sphere $S$ with radius $1$ centered at $O$. The surface area of $S$ is $4\pi$, where $\pi$ is the circle constant. For a face $C$ of the die, there exists a region $T$ on the sphere $S$ such that if the direction of gravity when the die lands intersects $S$ within $T$, then $C$ is the face that lands on the ground. The probability of $C$ landing is the area of region $T$ divided by $4\pi$. To assist in calculating the area of a region on the sphere, we provide the formula for the area of a triangle on the unit sphere $S$. Consider three great circles on the unit sphere $S$ that intersect each other, with intersection points $A$, $B$, and $C$. The area of the spherical triangle $ABC$ is $\text{Area}(ABC)=\alpha+\beta+\gamma-\pi$, where $\alpha$, $\beta$, and $\gamma$ are the magnitudes of the three dihedral angles, respectively, as shown in the figure below.

We guarantee that when any face lands, the projection of the center of mass onto the plane of that face lies within the face itself. That is, the die will not be unstable.

Input

The first line contains two integers, representing the total number of vertices $n$ and the total number of faces $f$, respectively, both numbered starting from $1$.

The next $n$ lines each contain three floating-point numbers $x$, $y$, and $z$, giving the coordinates of each vertex.

The next $f$ lines describe each face in order: first, an integer $d \geq 3$ is given, representing the number of vertices on that face, followed by $d$ integers giving the indices of the vertices in counter-clockwise order (viewed from outside the die).

Output

Output $f$ lines, where the $i$-th line contains a floating-point number representing the probability that the $i$-th face lands on the ground. Your output should be rounded to seven decimal places, i.e., it should be the closest value to the standard answer when rounded to seven decimal places. The data is guaranteed to avoid precision errors caused by rounding at the eighth decimal place.

Examples

Input 1

8 6
1 0 0
1 1 0
1 0 1
1 1 1
0 0 0
0 1 0
0 0 1
0 1 1
4 1 2 4 3
4 2 6 8 4
4 6 5 7 8
4 5 1 3 7
4 3 4 8 7
4 1 5 6 2

Output 1

0.1666667
0.1666667
0.1666667
0.1666667
0.1666667
0.1666667

Subtasks

$20\%$ of the data satisfies $n = f = 4$.

$60\%$ of the data satisfies $n, f \leq 10$.

For all data, $4 \leq n \leq 50$ and $4 \leq f \leq 80$, and the absolute values of all coordinates are within $10000$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.