QOJ.ac

QOJ

Points totaux : 100 Sortie uniquement

#8664. Compass and Straightedge Construction

Statistiques

A software engineering student, Little W, is in an engineering drawing exam, but he only brought a ruler with worn-out markings and a pair of compasses. Desperate, he turns to you, who possesses amazing geometric construction skills. Now, please use a ruler without markings and a pair of compasses to help Little W complete the drawing quickly and accurately.

We simplify this problem: assume Little W has already obtained a coordinate system and a unit length, and he needs you to construct a length $L_0$ using a ruler and compass, i.e., to obtain the point $(L_0, 0)$.

You can use the following three operations:

  1. line(A, B): Construct a line passing through point $A$ and point $B$.
  2. circle(O, A, B): Draw a circle with the distance between $A$ and $B$ as the radius, centered at point $O$.
  3. intersect(i, j): Mark the intersection point(s) of the $i$-th figure and the $j$-th figure; if there are multiple, mark all of them.

Initially, Little W provides you with the origin $O(0,0)$, which is point 0. The unit length is given by point 1 $(1,0)$. Additionally, the $x$-axis (figure 0) and $y$-axis (figure 1) are provided.

Points and figures obtained during the operations will be numbered sequentially. Let the current number be $n$. The point(s) generated by an operation will be numbered starting from $n+1$. If two figures do not intersect, no points are generated. If there are two intersection points, the one with the smaller $x$-coordinate (or the one with the same $x$-coordinate but smaller $y$-coordinate) will be numbered $n+1$, and the other will be $n+2$.

Please obtain the point $(L_0, 0)$ and indicate its number. You do not need to obtain the exact value, but your score is related to the difference between your result and the exact value, as well as the number of operations you use.

Input

This is an answer-submission problem. The input files draw1.in through draw10.in are already in the problem directory. Each input $L_0$ is a Python calculation expression. Here ** represents exponentiation, for example, 3 ** 2 represents $3^2$, and 2 ** 0.5 represents $\sqrt{2}$. To provide higher precision, the numbers in the expression are converted to Decimal type, i.e., high-precision decimals. For example, Decimal(2) represents 2. The input is guaranteed to contain numbers and operators, with a space between each operator and number. The output of the Python code is the number to be constructed. Note that the result calculated directly by Python is an approximate value, while the actual requirement is the exact value; that is, the value compared with the result obtained by the contestant is the exact value. Additionally, we have provided a file draw.pdf which gives the expressions for each group in a readable format.

Output

For the 10 given input files draw1.in through draw10.out, you need to submit your output files draw1.out through draw10.out respectively. The first line of the output file contains an integer $n$, representing the number of operations. The following $n$ lines each describe one operation. The formats for the three operations are:

line: L A B
circle: C O A B
intersect: I i j

The parameter meanings are as described in the problem statement. The last line of the output file contains an integer representing the number of the final point obtained.

Examples

Input 1

Decimal( 2 ) ** ( Decimal( 1 ) / Decimal( 2 ) )

Output 1

5 
C 0 0 1 
I 1 2
C 0 1 3 
L 1 3 
I 0 3
5

Note 1

The five operations in the example are as follows: 1. Draw a circle centered at point $O$ with unit length as the radius; this circle is figure 2. 2. Take the intersection of figure 2 (circle) and the $y$-axis; the intersection points are numbered 2 $(0, -1)$ and 3 $(0, 1)$. 3. Draw a circle centered at point $O$ with the distance between point 1 and point 3 as the radius; this circle is figure 3. 4. Connect points $(1, 0)$ and $(0, 1)$ to generate a line, which is figure 4. 5. Take the intersection of figure 3 (circle) and the $x$-axis; the intersection points are numbered 4 $(-\sqrt{2}, 0)$ and 5 $(\sqrt{2}, 0)$. Therefore, point 5 is the node that needs to be obtained.

Subtasks

For the 10 given input files draw1.in through draw10.in, we provide scoring parameter files draw1.ans through draw10.ans respectively. Each scoring parameter file contains ten lines, each with two values $c_i, x_i$, indicating that if the absolute difference between the $x$-coordinate of the final point $(x, 0)$ and $L_0$ does not exceed $10^{-x_i}$, and the number of operations used is $n \le c_i$, then you can get $i$ points. The judge will take the highest score that satisfies the conditions; if no conditions are met, you get 0 points.

Interaction

We provide a tool called checker to test whether your output file is acceptable. To use this tool, first enter the terminal, run the following command in the terminal to enter the problem folder: cd draw Then run: ./checker <case_no> where case_no is the number of the test data. For example: ./checker 3 This will test whether draw3.out is acceptable. After you call this program, checker will provide the test results based on the output file you provided, including: 1. Abnormal exit: Unknown error. 2. Invalid parameters for checker.: The parameters passed to checker are invalid. 3. Input/Output file does not exist.: The input/output file does not exist. 4. Output invalid: The output file is incorrect and may contain specific error information. 5. Correct! Your answer is n. Your score is s.: The output is acceptable, the number of operations used is $n$, and the score for this test case is $s$.

Note

We can use Python to obtain the approximate value of the expression. Specifically, after running python in the terminal, enter:

from math import *
from decimal import *
getcontext().prec = 100

Then copy the expression (Python code) from the input file into the terminal window and press Enter to get the approximate value of the expression (the 100 in the code above can be replaced with the precision you want).

If you use self-generated input files for debugging, checker might fail due to excessive scale. If this happens, try smaller-scale data. Please keep your input files draw*.in, your output files draw*.out, and the scoring parameter files draw*.ans safe and backed up to avoid accidental deletion.


ou importez des fichiers un par un

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.