Sweep line


Marisa wants to run a sweep line algorithm on a set of points. In a sweep line algorithm, the point with the lowest x-value gets processed first, then the 2nd lowest x, then the 3rd, until the point with the highest x gets processed. If 2 points have the same x-value, then they the point with the lower y-value is processed first.

Marisa wonders how the order would change if all the points are rotated. If she rotates all points around the origin by angang degrees counterclockwise, what would be the x-value (after rotation) of the last point processed by a sweep line algorithm?

Since Marisa is studious, she has many values of angang for which she wants the x-value of last point processed.

Input

The first line has 2 integers, nn, mm, the number of points, and the number of values of angang

The next nn lines each have 2 integers, xix_i yiy_i, the x and y value of the ith point. All points are distinct.

The next mm lines have one value, angiang_i, a float which gives the amount in degrees the points are rotated by. Each value of angiang_i represents an independent case, so do not apply rotations successively.

1<=n<=1e51 <= n <= 1e5

1<=m<=1e41 <= m <= 1e4

−1e4<=xi,yi<=1e4-1e4 <= x_i, y_i <= 1e4

0<=angi<3600 <= ang_i < 360

Output:

For every value of angiang_i, write one line with the answer for that query. The answer being the last x-value processed if the original points were rotated by angiang_i degrees counterclockwise.

Sample Input:

Input 1
3
0 0 
1 1
0 1

Sample Output:

Output 1
0.2928931713

Sample Input:

Input 2
4
1 1
3 1
3 4
1 4

Sample Output:

Output 2
2

Sample Input:

Input 3
5
0 0
1 0
1 1
0 2
-1 1

Sample Output:

Output 3
0.1291712523

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.