QOJ.ac

QOJ

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

#4530. Polygon Goes to Sea

Estadísticas

In a two-dimensional space, given a convex polygon with a surface density of $\rho$, it is placed into an infinite pool of water with a horizontal surface at $y=0$ and a water density of $1$. Find the counter-clockwise rotation angle of the convex polygon when it is at rest and its potential energy reaches its minimum.

The potential energy includes the gravitational potential energy of the convex polygon itself and the buoyancy potential energy generated by the work done by buoyancy.

Input

The first line contains an integer $N$, representing the number of test cases. For each test case: The first line contains an integer $n$ and a floating-point number $\rho$, representing the number of vertices of the polygon and the density of the polygon, respectively. The next $n$ lines each contain two floating-point numbers $x, y$, representing the vertices of the convex hull in counter-clockwise order.

Output

For each test case, output a single line containing $\theta$, the counter-clockwise rotation angle in radians when the convex polygon reaches its minimum potential energy, where $0 \leq \theta < 2\pi$.

This problem uses a Special Judge. An error of $10^{-6}$ is allowed for your output. Please output as many decimal places as possible (but do not exceed 15 decimal places).

Examples

Input 1

3
3 0.3
0.23272177 0.50274749
0.69314977 0.57621227
0.63404493 0.80356643
7 0.7
0.97651045  0.03790015
0.9919297   0.75416081
0.76345204  0.83482219
0.17087067  0.83086959
0.19621027  0.49532965
0.24676201  0.45389929
0.67563998  0.14424922
8 0.6
0.03726264  0.10180906
0.50450581  0.13303585
0.81055071  0.29025366
0.99405094  0.68868719
0.77510244  0.87181985
0.40531889  0.91965237
0.27990499  0.84662178
0.07581749  0.30329282

Output 1

2.60634462
3.83816499
2.50530629

Note

The visualizations for the three data sets above are as follows:

  • Green represents the shape of the polygon at rest with minimum energy,
  • Gray represents the original polygon,
  • Blue represents the water surface.

Constraints

The convex polygon is given in counter-clockwise order.

The number of test cases $N \leq 10$.

$0.1 < \rho < 0.9$.

$0 \leq x, y \leq 1$.

For 30% of the data, $n=3$.

For 60% of the data, $n \leq 100$.

For 100% of the data, $n \leq 100000$, $\sum n \leq 100000$.

The data is guaranteed to form a convex polygon, the distance between any two adjacent points on the polygon is at least $10^{-10}$, and the area of the polygon is at least $10^{-4}$.

The data is guaranteed to have a unique solution.

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.