Connection Status:
Competition Arena > ThreeTrees
TCC19 India Qualifiers · 2019-05-04 · by erinn · Brute Force
Class Name: ThreeTrees
Return Type: double
Method Name: area
Arg Types: (vector<int>, vector<int>, int)
Problem Statement

Problem Statement

You are looking to plant a new tree somewhere in your field, which 10 meters wide and 10 meters long. The must be planted at a location that is at least distance away from where any other tree is planted. You are given the location of any other trees in int[]s x and y, where (x[i], y[i]) indicates the location of the i-th tree.

Calculate the total area in which it would be safe to plant the new tree.

Notes

  • Your return value must be within 1e-6 absolute or relative error to be considered correct.

Constraints

  • x will have between 0 and 3 elements, inclusive.
  • x and y will have the same number of elements.
  • Each element of x will be between 0 and 10, inclusive.
  • Each element of y will be between 0 and 10, inclusive.
  • distance will be between 0 and 20, inclusive.
Examples
0)
{5}
{5}
5
Returns: 21.460183689207042

There's a circle of radius 5, centered right in the center of the field, in which we cannot plant the tree. Thus our answer is 100 - pi * 5^2.

1)
{2, 8}
{2, 8}
2
Returns: 74.86725878970901

Here, there's two circles of radius two that are not available, so we calculate 100 - 2 * pi * 2^2.

2)
{0, 1, 5}
{0, 0, 3}
6
Returns: 17.95288785134835

Three trees, and whole lot of area that isn't suitable.

3)
{0}
{0}
20
Returns: 0.0

In a 10x10 field with even a single tree already planted, there's nowhere to put another without being too close to the existing tree.

4)
{1, 8, 7}
{1, 9, 2}
4
Returns: 23.73397466186816

Submissions are judged against all 33 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class ThreeTrees with a public method double area(vector<int> x, vector<int> y, int distance) · 33 test cases · 2 s / 256 MB per case

Submitting as anonymous