Atena

Time limit: 2s Memory limit: 256MB Input: Output:

Plato and Aristotle, good friends, had gotten lost in Athens. One could say they have a platonic friendship. However, they had moved so far apart that they could not hear each other directly even when shouting. Thus, they needed an intermediary: Pythagoras. When the two friends stand still, Pythagoras can calculate using his knowledge the area of the zone where he must be located to hear them both and transmits the information to them via Morse code in IEEE 754 format. Plato, being old, could not move as quickly as his disciple Aristotle, so he chose to remain stationary.

In this problem you are in Aristotle's situation. The committee has a hidden circle C1\mathscr{C}_1 with center (X,Y)(X, Y) (representing Plato's position) and radius RR (at which the philosopher's voice can be heard). The contestant must find the numbers (X,Y,R)(X, Y, R) using as few questions as possible of the type: Let C2\mathscr{C}_2 be a circle with center (x,y)(x', y') and radius rr' (representing Aristotle's position and his lung capacity). What is the area of intersection of circles C1\mathscr{C}_1 and C2\mathscr{C}_2?

We consider that x,y,rx', y', r' are all three numbers chosen by the contestant with the following constraints:

  • 107x107-10^7 \leq x' \leq 10^7
  • 107y107-10^7 \leq y' \leq 10^7
  • 0<r1070 < r' \leq 10^7

By the area of intersection of two circles we mean the area of the common portion of the disks determined by these circles.

Task

Write a program that guesses using as few questions as possible and as accurately as possible the coordinates of the circle. The score will be awarded based on the number of questions and the precision with which the answer is given.

Note: Contestants will be provided with several helper geometric functions to simplify the implementation.\textbf{Note: Contestants will be provided with several helper geometric functions to simplify the implementation.}

Interaction Protocol

The contestant must implement exclusively the function

std::vector<double> solve();

The function will return a vector v=(v1,v2,v3)v = (v_1, v_2, v_3) of 33 elements with the property that X=v1,Y=v2,R=v3X = v_1, Y = v_2, R = v_3. The contestant does not need to implement the main function.

To ask questions, the contestant can call the function:

double query(double x, double y, double r);

The function will return the area of intersection between the circle with center (x,y)(x, y) and radius rr and the hidden circle C1\mathscr{C}_1 from the committee.

Attached Files

Participants have access to the following files:

  • atena.h -- the header that defines the interaction functions (solve and query) necessary for implementation.
  • atena.cpp -- a simple implementation example that executes one query and answers with the circle (1,2,3)(1, 2, 3) each time.
  • lgrader.cpp -- a testing grader for participants that can help them verify their code. A different grader will be used for scoring submissions.
  • geometry.h -- a file with multiple geometry functions to ease contestants' implementation.

Using lgrader in Code::Blocks

To use lgrader.cpp in Code::Blocks:

  • Create a new project.
  • Add a file named solutie.cpp (select File > New > Empty File), where you will write the solution code.
  • Add an empty file named atena.h and copy the contents from the attached atena.h file
  • Copy the contents from lgrader.cpp into main.cpp to simulate running the solution.

After this setup, write in solutie.cpp the implementation of the solve function. To test the configuration, you can initially copy the code from atena.cpp into solutie.cpp. Then, press F9 or select Build and Run to compile and run the program. When running, the program will read the values XX, YY and RR, and will simulate the interaction between lgrader and the contestant's solution, displaying the answers to queries made through query and validating the final answer provided through solve.

Constraints

  • Let C1\mathscr{C}_1 be the hidden circle from the committee with center (X,Y)(X, Y) and radius RR.
  • 106X106-10^6 \leq X \leq 10^6
  • 106Y106-10^6 \leq Y \leq 10^6
Warning!104R106\textcolor{red}{\mathbf{Warning!}} \quad \mathbf{10^{\textcolor{red}{4}} \leq R \leq 10^{\textcolor{red}{6}}}

Scoring

Let D=(xX)2+(yY)2+(rR)2D = (x - X)^2 + (y - Y)^2 + (r - R)^2 be the error margin of the answer and QQ the number of questions asked by the contestant.

Let CDC_D and CQC_Q be two scoring coefficients defined as follows:

CD={1D<1052log10(D)7105D1020D>102C_D = \begin{dcases} 1 & D < 10^{-5} \\ \frac{2 - \log_{10}(D)}{7} & 10^{-5} \leq D \leq 10^2 \\ 0 & D > 10^2 \\ \end{dcases}CQ={1Q20(70Q50)1.30.3+0.720<Q707803Q1900+0.470<Q2605000Q14960+0.15260<Q50000Q>5000C_Q = \begin{dcases} 1 & Q \leq 20 \\ \left(\frac{70 - Q}{50}\right)^{1.3} \cdot 0.3 + 0.7 & 20 < Q \leq 70 \\ \frac{780 - 3Q}{1900} + 0.4 & 70 < Q \leq 260 \\ \frac{5000 - Q}{14960} + 0.15 & 260 < Q \leq 5000 \\ 0 & Q > 5000 \\ \end{dcases}

Then your score for a test will be 100CDCQ%100 \cdot C_D \cdot C_Q \% of the maximum for the test.

It is guaranteed that for tests worth 2020 points the center of the hidden circle is on the \texttt{Ox} axis.

Example Interaction

The hidden circle is C1(X=17.00000,Y=2.62331,R=6.7890)\mathscr{C}_1(X=17.00000, Y=2.62331, R=6.7890). This case cannot be manifested in the test data as RR does not meet the lower bound of 10410^4.

An example interaction is as follows:

query(1, 1.5, 2.5)

The area of intersection between the hidden circle C1\mathscr{C}_1 and the circle (1,1.5,2.5)(1, 1.5, 2.5) is 00.

query(15, 14, 7)

The area of intersection between circle C1\mathscr{C}_1 and circle (15,14,7)(15, 14, 7) is 11.42900097811.429000978.

return {17.000001, 2.62331, 6.7891};

It is observed that, although the returned values do not exactly match the real ones, the solution is considered correct because the error margin is less than 10510^{-5}.

Log in or sign up to be able to send submissions!