Playrix Codescapes Cup (Codeforces Round 413, rated, Div. 1 + Div. 2)
G
Cut the pie
Codeforces
3500
原题
← F→
翻译中…

Arkady reached the $*n*$-th level in Township game, so Masha decided to bake a pie for him! Of course, the pie has a shape of convex $*n*$-gon, i.e. a polygon with $*n*$ vertices.

翻译中…

Arkady decided to cut the pie in two equal in area parts by cutting it by a straight line, so that he can eat one of them and give the other to Masha. There is a difficulty because Arkady has already put a knife at some point of the pie, so he now has to cut the pie by a straight line passing trough this point.

翻译中…

Help Arkady: find a line that passes through the point Arkady has put a knife into and cuts the pie into two parts of equal area, or determine that it's impossible. Your program has to quickly answer many queries with the same pie, but different points in which Arkady puts a knife.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$ and $*q*$ ($3 ≤ *n* ≤ 10^{4}$, $1 ≤ *q* ≤ 10^{5}$) — the number of vertices in the pie and the number of queries.

翻译中…

$*n*$ line follow describing the polygon vertices in clockwise order. The $*i*$-th of these line contains two integers $*x*_{*i*}$ and $*y*_{*i*}$ ($- 10^{6} ≤ *x*_{*i*}, *y*_{*i*} ≤ 10^{6}$) — the coordinates of the $*i*$-th vertex. It is guaranteed that the polygon is strictly convex, in particular, no three vertices line on the same line.

翻译中…

An empty line follows.

翻译中…

$*q*$ lines follow describing the query points. The $*i*$-th of these lines contain two integers $*x*_{*i*}$ and $*y*_{*i*}$ ($- 10^{6} ≤ *x*_{*i*}, *y*_{*i*} ≤ 10^{6}$) — the coordinates of the point in which Arkady puts the knife in the $*i*$-th query. In is guaranteed that in each query the given point is strictly inside the polygon, in particular, is not on its edges.

翻译中…

Output

翻译中…

For each query print single integer — the polar angle of the line that is the answer for the corresponding query, in radians. The angle should be in the segment $[0;π]$, the angles are measured from the direction of $*OX*$ axis in counter-clockwise order. For example, the polar angle of the $*OY*$ axis is image. If there is no answer in that query, print -1.

翻译中…

If there are several answers, print any of them. Your answer is considered correct if the difference between the areas of the parts divided by the total area of the polygon doesn't exceed $10^{ - 4}$ by absolute value. In other words, if $*a*$ and $*b*$ are the areas of the parts after the cut, then your answer is correct if and only of image.

翻译中…

样例

Input #1
3 1
0 0
0 3
3 0

1 1
Output #1
2.67794504460098710000
InputCopy OutputCopy
Input #2
5 3
6 5
6 3
5 0
0 0
0 5

5 4
3 3
5 2
Output #2
0.60228734612690049000
1.27933953226473580000
2.85805511179015910000
InputCopy OutputCopy
题目信息
题号
799G
时间限制
3 s
内存限制
256 MB
标签
二分
数据结构
计算几何

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。