Find Lighted Area

All submissions for this problem are available.

You are given a square with side length 2*L. The coordinates of its vertices are at (-L, -L), (L, -L), (L, L) and (-L, L). You are also given N disks (each disk is opaque, and light rays cannot pass through them) each of radius R. The centers of each of the disks are at a fixed distance D from origin (0, 0). This distance D is strictly greater than R. It is guaranteed that all the disks lie entirely inside the square.

Suppose, there is a light source at the origin. Find the area of the region of the square that will be lit by this light source. A point inside the square will be lit if the line segment between the origin and the point don't intersect or touch any of the discs.

All distances mentioned are Euclidean distances.

Input

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

The first line of each test case contains four integers: N, R, D, L.

Each of the next N lines contain two space separated real numbers denoting the x and y coordinates of the center of the i-th disk. Each real number may contain up to 16 digits after the decimal point. These coordinates will satisfy all the conditions mentioned in the statement, i.e.
they will be at distance exactly D from the origin.

Output

For each test case, output a real number representing the illuminated area. Your answer will be considered correct if the absolute or relative error of the answer doesn't exceed 10-6.

Constraints

1 ≤ T ≤ 105

1 ≤ N ≤ 105

2 ≤ D ≤ 105

1 ≤ R < D

R + D < L ≤ 3 * 105

-106 ≤ x, y ≤ 106

Sum of N over all the test cases in a single file would be at most 4 * 105

For any two centers of disks, it is guaranteed that the distance between them is ≥ 10-6.

Example

Explanation

More examples are given in the webpage, but not printed here. Please check them as well.

The image below shows the scenario for testcase 1:

ABCD represents the square, which has coordinates according to L = 4. The only circle is at coordinates (2, 0). Notice that the distance of the center from the origin is 2, which is L. Its radius is R = 1. The light source is at (0, 0).

The grayed area along with the circle represents the area which is not lit by the light source. The area of the whole square with this area subtracted is the answer.

Comments

Please login at the top to post a comment.

SUCCESSFUL SUBMISSIONS

Fetching successful submissions

HELP

Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.

Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.

Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.

Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.

Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to INR 20,000 (for Indian Community), $700 (for Global Community) and lots more CodeChef goodies up for grabs.