#P7380. [COCI 2018/2019 #6] Konj
[COCI 2018/2019 #6] Konj
Description
Domagoj has a strange way of drawing. First, he prepared line segments to be drawn. Each segment connects two points, namely and . Then, he chooses a point . After that, Domagoj will draw all segments that satisfy at least one of the following conditions:
- They pass through point .
- They are directly or indirectly connected to a segment that passes through point .
We say that two segments are directly connected if they share an endpoint. We say that are indirectly connected if is directly connected to , is directly connected to , , and is directly connected to .
Your task is to print the final drawing made by Domagoj. The output should be in the form of a matrix . If there is a segment passing through , output # at position ; otherwise, output the character .. Note that the horizontal coordinate increases from left to right, and the vertical coordinate increases from bottom to top (consistent with the Cartesian coordinate system). The matrix must not contain any row or column consisting entirely of . characters. That is, while containing all segments that need to be drawn, the matrix must be the smallest possible in size.
Input Format
The first line contains the number of segments to be drawn, .
The next lines each contain four non-negative integers , representing the endpoints and of the -th segment. For each segment, exactly one of and holds. In other words, every segment is parallel to one of the coordinate axes. Also, no segments intersect, but they may share endpoints.
The next line (the last line) contains integers , representing the coordinates of . It is guaranteed that at least one segment passes through point .
Output Format
Output the required matrix .
15
2 2 6 2
2 2 2 6
6 2 6 4
6 4 6 6
2 6 6 6
6 2 8 2
8 2 10 2
10 2 12 2
12 2 12 4
12 4 6 4
6 2 6 1
8 2 8 0
10 2 10 1
12 2 12 0
42 42 42 43
2 2
#####......
#...#......
#...#######
#...#.....#
###########
....#.#.#.#
......#...#
6
1 1 10 1
10 1 10 3
10 3 1 3
1 3 1 1
10 3 11 3
11 3 11 6
2 1
..........#
..........#
..........#
###########
#........#.
##########.
Hint
Explanation for Sample 1
All segments except the last one need to be drawn. That is, except for the segment connecting and , all others must be drawn.
Explanation for Sample 2
All segments must be drawn.
Constraints
For of the testdata, all segments need to be drawn.
For of the testdata, , .
Notes
The score for this problem follows the original COCI setting, with a full score of .
Translated from COCI2018-2019 CONTEST #6 T2 Konj.
Translated by ChatGPT 5
京公网安备 11011102002149号