50003. Turtle Graphics

I'm a slow walker, but I never walk backwards.

Problem description

There is an old drawing program called turtle graphics. The program is given a series of $L$ lines and it will draw them on an $X$ by $Y$ matrix. A line consists of a series of $n$ points, and the program will draw a straight line between two consecutive points. For simplicity we assume that the each segment of a line is either vertical, horizontal, or $45^{\circ}$ diagonal.

The input is as follow. The first line has $L$, $X$, and $Y$. All of them are between 1 and 100. Each of the next $L$ lines starts with $n$, the number of points in that line, and the next $n$ pairs of coordinates indicate the position of the points in the that line. Note that $n$ is positive and could be very large so you cannot store the coordinates in an array. If you are given a point that is not in the grids, or does not form a vertical, horizontal, or $45^{\circ}$ diagonal line with the previous point, report the line number and point number and stops the program.

If the input is correct, then the output has $X$ lines, each of them has $Y$ numbers. You should output a $1$ if that cell is drawn, $0$ otherwise. If the input is incorrect report the line number and point number of the point that is causing the problem. Both line number and point number start from $1$.

Technical Specification and constraints

  • 10 pt. $L$ is $1$ and the line is a valid horizontal line, i.e, $n$ is $2$.
  • 30 pt. $L$ is $1$ and the lines are only horizontal and vertical, $n$ is between $1$ and $10$, and the input is always correct.
  • 40 pt. $L$ is between $1$ and $100$ and the lines could be vertical, horizontal, or $45^{\circ}$ diagonal, $n$ is between $1$ and $10$, and the input is always correct.
  • 10 pt. $L$ is between $1$ and $100$ and the lines could be vertical, horizontal, or $45^{\circ}$ diagonal, $n$ is between $1$ and $10$, and input could be incorrect.
  • 10 pt. $L$ is between $1$ and $100$ and the lines could be vertical, horizontal, or $45^{\circ}$ diagonal, $n$ could be very large so you CANNOT store the points in an array, and input could be incorrect.

Sample Input 1

1 5 6
2 5 4 0 4

Sample Output 1

111111
000000
000000
000000
000000

Sample Input 2

2 5 6
2 5 4 0 4
3 4 2 1 2 3 0

Sample Output 2

111111
000000
011110
001000
000100

Sample Input 3

3 5 6
2 5 4 0 4
3 4 2 1 2 3 1
2 5 4 5 0

Sample Output 3

ERROR 2 3

Sample Input 4

1 5 6
5 3 3 0 3 3 0 0 0 0 2

Sample Output 4

000000
111100
110000
101000
111100

Discussion