#P7380. Domagoj's Connected Drawing

    ID: 20576 Type: Default 1000ms 256MiB

Domagoj's Connected Drawing

Domagoj's Connected Drawing

Domagoj has a peculiar style of painting. He initially prepares \(N\) line segments. The \(i\)-th line segment connects two points \((A_i, B_i)\) and \((C_i, D_i)\). Then, he chooses a point \(T = (T_x, T_y)\). Domagoj will draw a line segment if either:

  • The segment passes through \(T\) (i.e. \(T\) lies on the segment), or
  • The segment is directly or indirectly connected to a segment that passes through \(T\).

Two segments are directly connected if they share an endpoint. They are indirectly connected if there exists a chain of segments \(L_1, H_1, H_2, \dots, H_k, L_2\) such that every two consecutive segments in the chain are directly connected.

Your task is to print the final drawing. The drawing is represented as a matrix \(P\) where for a grid point \((a, b)\) if some drawn segment passes through it then \(P(a,b) = \#\), otherwise \(P(a,b) = .\). The coordinate \(a\) increases from left to right and \(b\) increases from bottom to top. The matrix must be minimal, i.e. it should not have any row or column that consists entirely of the character ".", while still containing all the drawn segments.

inputFormat

The first line contains three integers: \(N\), \(T_x\) and \(T_y\) \( (1 \leq N \leq 10^3) \).

Then, \(N\) lines follow. The \(i\)-th of these lines contains four integers \(A_i\), \(B_i\), \(C_i\), \(D_i\) representing the endpoints of the \(i\)-th segment. All coordinates are integers with absolute value at most \(10^3\).

outputFormat

Output the drawing as a matrix. The rows correspond to increasing \(b\) (from bottom to top) but the output must print the top row first. Each row is a string of characters where the \(j\)-th character corresponds to the point with \(a\) coordinate increasing from left to right. The matrix must be minimal, i.e. it should not have any row or column that consists entirely of ".", while still containing all marked points where a drawn segment passes.

sample

3 0 0
-1 0 1 0
1 0 1 1
2 2 3 3
..#

###

</p>