eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

ASCII Art

ASCII Art

ASCII art is an art of creating pictures with a grid of ASCII characters. There are many styles of ASCII art, but we are interested in the most primitive one, where just an overall character density is used to represent differently shaded areas of the picture. You should write a proof-of-concept program that renders a filled closed polygon with a rectangular grid of ASCII characters. The whole process is explained in detail below. Let \textbf{OXY} be a Cartesian coordinate system with \textbf{OX} pointing to the right and \textbf{OY} pointing up. Drawing canvas is bounded with (\textbf{0}, \textbf{0})--(\textbf{w}, \textbf{h}) rectangle. Pixels on the canvas are (\textbf{x}, \textbf{y})--(\textbf{x+1}, \textbf{y+1}) squares where x and y are integers such that \textbf{0} ≤ \textbf{x} < \textbf{w} and \textbf{0} ≤ \textbf{y} < \textbf{h}. A filled closed polygon without self-intersections and self-touchings (but not necessarily convex) is drawn on the canvas. Pixels of the canvas become partially filled during the process. Each pixel is represented by an ASCII character depending on the percentage of its filled area according to the following table: The resulting ASCII characters for all pixels are printed top-to-bottom and left-to-right to get a visual representation of the drawing. \InputFile The first line of the input contains integers \textbf{n}, \textbf{w}, and \textbf{h} (\textbf{3} ≤ \textbf{n} ≤ \textbf{100}, \textbf{1} ≤ \textbf{w}, \textbf{h} ≤ \textbf{100}) --- number of vertices in the polygon, width and height of the canvas respectively. The following \textbf{n} lines contain coordinates of the polygon vertices in clockwise order. Point i is described by two integers \textbf{x_i} and \textbf{y_i} (\textbf{0} ≤ \textbf{x_i} ≤ \textbf{w}, \textbf{0} ≤ \textbf{y_i} ≤ \textbf{h}). \OutputFile Write to the output \textbf{h} lines with \textbf{w} ASCII characters each that represent ASCII art drawing of the given polygon.
Лимит времени 2 секунды
Лимит использования памяти 64 MiB
Входные данные #1
6 8 7
7 6
1 0
1 7
5 5
2 4
2 3
Выходные данные #1
.$+.....
.##$+...
.#$oo+..
.#+$o...
.##o....
.#o.....
.o......