QOJ.ac

QOJ

總分: 100 互動

#12574. Satellite Detection

统计

Country A recently detected abnormal radiation within Country B. Investigations revealed that Country B is spending billions to develop a new type of weapon—a "Chain Array." However, due to the high level of secrecy surrounding this weapon, Country A's spies cannot even determine the exact location of the Chain Array. Nevertheless, Country A's satellites can still locate the base where the Chain Array is situated. We now know that this base is a convex polygon containing radioactive material along its edges. Research has shown that in the plane where this convex polygon lies, it has the following properties:

  • It contains the coordinate origin.
  • No two edges are on the same line.
  • There are no edges parallel to the $x$-axis or $y$-axis.
  • The $x$ and $y$ coordinates of all vertices are integers.

Now, Country A can emit an infinitely large fan-shaped detection wave from a satellite, which intersects the plane of the convex polygon along a straight line. This line is either parallel to the $x$-axis or the $y$-axis. Through reflected signals, we can determine the number of intersection points between this line and the convex polygon, as well as the coordinates of all intersection points (if any).

You are required to write a program that determines this convex polygon by controlling the detection waves emitted by the satellite.

Interaction

This is an interactive problem. Your program must interact with the testing library and must not access any files. The testing library provides three sets of functions for program initialization, interaction with the library, and returning the results. Their usage and functions are as follows:

  • prog_initialize must be called first and can only be called once to initialize the testing library.
  • The testing library provides two functions, ask_x and ask_y, as a way to interact with the library. The function ask_x(x0, y1, y2) is used to query the intersection of the line $x=x_0$ with the polygon, and ask_y(y0, x1, x2) is used to query the intersection of the line $y=y_0$ with the polygon. The return value of the functions is the number of intersection points. After calling ask_x(x0, y1, y2), $y_1$ and $y_2$ are assigned the $y$-coordinates of the intersection points. After calling ask_y(y0, x1, x2), $x_1$ and $x_2$ are assigned the $x$-coordinates of the intersection points. If there is only one intersection point, the values of $x_1$ and $x_2$ (or $y_1$ and $y_2$) are the same. If there are no intersection points, the values of $x_1$ and $x_2$ (or $y_1$ and $y_2$) are meaningless.
  • The final set of functions is used by your program to return the results to the testing library. This includes returning the polygon area ret_area(s), returning the number of polygon vertices ret_n(n), and returning the polygon vertex coordinates ret_vertex(x, y). Note that ret_area must be called before ret_n, and ret_n must be called before ret_vertex. Improper calling sequences will force your program to terminate illegally. You must call ret_vertex $n$ times after calling ret_n to return the vertices of the polygon. Note that if the result returned by ret_n is incorrect, the testing library will immediately terminate your program and will not accept subsequent results. Similarly, if an incorrect result is returned in ret_vertex, the testing library will also immediately terminate your program. If all results from ret_vertex are correct, the testing library will terminate your program after you return the last vertex coordinate.
  • You must return the coordinates of all vertices in counter-clockwise order, but you may start from any vertex.

Implementation Details

For Pascal users, your program should reference the testing library using the following statement: uses detect_lib;

The function prototypes used by the testing library are:

procedure prog_initialize;
function ask_x(const x0: longint; var y1, y2: double): longint;
function ask_y(const y0: longint; var x1, x2: double): longint;
procedure ret_area(const s: double);
procedure ret_n(const n: longint);
procedure ret_vertex(const x, y: longint);

For C/C++ users, you should create a project, include the file libdetect.o, and add the following line to the beginning of your program: #include "detect_lib.h"

The function prototypes used by the testing library are:

void prog_initialize();
int ask_x(int x0, double *y1, double *y2);
int ask_y(int y0, double *x1, double *x2);
void ret_area(double s);
void ret_n(int n);
void ret_vertex(int x, int y);

Constraints

The maximum value of $n$ is $200$, and the $x$ and $y$ coordinates are in the range $[-10000, 10000]$.

Scoring

If your program exhibits any of the following, it will receive 0 points: Accessed any file (including temporary files) or terminated itself. Called library functions illegally. * Caused the testing library to exit abnormally.

Otherwise, your score for each test case is calculated as follows: 1 point for a correct number of vertices, 2 points for a correct area, and 2 points for completely correct vertex coordinates, with scores being cumulative. The remaining 5 points will be judged based on the total number of times you call ask_x and ask_y.

Examples

Input 1

(Interactive problem, no input file)

Output 1

(Interactive problem, no output file)

或者逐个上传:

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.