#P7195. [IOI 2019] 折线
[IOI 2019] 折线
Background
You can download the input files here.
Problem Description
Azerbaijan is famous for its carpets. As a master carpet designer, you want to draw a polyline in your new design. A polyline is a sequence of line segments in the 2D plane consisting of segments. These segments are defined by a sequence of points as follows: for every , there is a segment connecting points and .
To complete this new design, you have already marked small dots in the 2D plane. The coordinates of small dot () are . There are no two small dots with the same coordinate or the same coordinate.
Now you want to find a point sequence such that the polyline defined by this sequence satisfies:
- The polyline starts from (i.e., and ),
- The polyline passes through all small dots (they do not have to be endpoints of segments), and
- The polyline consists only of horizontal and vertical segments (for any two consecutive points defining the polyline, their coordinates or their coordinates are equal).
The polyline may self-intersect or overlap in any way. Formally, each point on the plane may belong to any number of segments of the polyline.
This is a partial-scoring output-only problem. You will be given input files that specify the positions of the small dots. For each input file, you need to submit an output file describing a polyline that satisfies the requirements. For each output file that provides a valid polyline, your score depends on the number of segments in the polyline (see the Scoring section below).
You do not need to submit any source code for this problem.
Input Format
Each input file has the following format:
- Line : .
- Line (here ): .
Output Format
Each output file must follow the format below:
- Line : .
- Line (here ): .
Note that the second line should contain and (that is, the output must not include and ). All and must be integers.
4
2 1
3 3
4 4
5 2
6
2 0
2 3
5 3
5 2
4 2
4 4
Hint
Sample explanation
This sample is not from any of the actual testdata; it is only meant to help you understand the statement.
The output shown is also only one possible output.

Constraints
- .
- .
- All values of and are integers.
- There are no two small dots with the same coordinate or the same coordinate, i.e., for all , we have and .
- .
- The size of each submitted file (whether an output file or a compressed file) must not exceed .
Scoring
For each test case, you can score at most points. If you output an invalid polyline, you will get points. Otherwise, your score is computed using a decreasing sequence .
Suppose your solution is a valid polyline with segments. Then you will get:
- points, if ().
- points, if ().
- points, if .
- points, if .
This can be understood as follows: on the interval , your score increases linearly as decreases. Once you score, the score is guaranteed to be within .
Below is the information about and for each test case:
| Test case | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Visualization tool
In the additional files for this problem, there is a script that can visualize the input files and output files.
To visualize an input file, use the following command:
python vis.py [input file]
For a given input, you can also visualize your solution with the command below. Due to technical limitations, the visualization tool only shows the first segments in the output file.
python vis.py [input file] --solution [output file]
For example:
python vis.py examples/00.in --solution examples/00.out
Translated by ChatGPT 5