当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3148: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 OXY be a Cartesian coordinate system with OX pointing to the right and OY pointing up. Drawing canvas is bounded with (0, 0) – (w, h) rectangle. Pixels on the canvas are (x, y) – (x + 1, y + 1) squares where x and y are integers such that 0 ≤ x < w and 0 ≤ y < 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:

Pixel percentage area filled CharacternameGlyphASCII code
From 0% inclusive to 25% exclusiveFull stop.46
From 25% inclusive to 50% exclusivePlus sign+43
From 50% inclusive to 75% exclusiveSmall letter oo111
From 75% inclusive to 100% exclusiveDollar sign$36
100%Number sign#35

The resulting ASCII characters for all pixels are printed top-to-bottom and left-to-right to get a visual representation of the drawing.

输入解释

The first line of the input file contains integers n, w, and h (3 ≤ n ≤ 100, 1 ≤ w, h ≤ 100) — number of vertices in the polygon, width and height of the canvas respectively. The following n lines contain coordinates of the polygon vertices in clockwise order. Point i is described by two integers xi and yi (0 ≤ xi ≤ w, 0 ≤ yih).

输出解释

Write to the output file h lines with w ASCII characters each that represent ASCII art drawing of the given polygon.

输入样例
6 8 7
7 6
1 0
1 7
5 5
2 4
2 3
输出样例
.$+.....
.##$+...
.#$oo+..
.#+$o...
.##o....
.#o.....
.o......

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3148

最后修改于 2020-10-29T06:54:16+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536