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

建议使用的浏览器:

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

2270:Quadtree II or: Florida Jones strikes back

题目描述
Having realized that the quadtree-encoded treasure map was a fake, Florida Jones maliciously plans to also play a prank for the next treasure hunter after him. But for that, he needs your help once again:

Can you write a program that takes a picture in the XBM format and encodes it with the quadtree scheme?
输入解释
The first line will be "#define quadtree_width n" where n is the picture size in pixels. (The picture is quadratic: n*n pixels)
The second line will be "#define quadtree_height n" accordingly.
The third line will be "static char quadtree_bits[] = {".
Then, n lines will follow, each one encoding one pixel row of the picture. There will be n/8 hexadecimal numbers per line.
Each hexadecimal number is composed of 8 bits that encode 8 pixels from left to right (where the leftmost bit has the value 1 and the rightmost bit has the value 128). The hexadecimal numbers are printed in the form 0xdd where d is one character of the set { 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f }.
Example: The 8 pixels WBBBBWWB are written as 0x9e. (2+4+8+16+128 = 158 = 0x9e)
After each hexadecimal number, a comma follows.
The last line will be "};".
Note: The comments (enclosed by /* and */) in the sample input are not part of the input. They should help to explain the XBM format
输出解释
First, print the integer n (8 <= n <= 512) on a line by itself.
Then, print a string consisting of the letters B, W and Q that correctly encodes the picture with the quadtree scheme.
Finally, terminate the string with a newline character.
输入样例
#define quadtree_width 16
#define quadtree_height 16
static char quadtree_bits[] = {
0xf0,0xf0,                       /* WWWWBBBB WWWWBBBB */
0xf0,0xf0,                       /* WWWWBBBB WWWWBBBB */
0xf0,0xf0,                       /* WWWWBBBB WWWWBBBB */
0xf0,0xf0,                       /* WWWWBBBB WWWWBBBB */
0x0f,0x0f,                       /* BBBBWWWW BBBBWWWW */
0x0f,0x0f,                       /* BBBBWWWW BBBBWWWW */
0x0f,0x0f,                       /* BBBBWWWW BBBBWWWW */
0x0f,0x0f,                       /* BBBBWWWW BBBBWWWW */
0xf0,0xf0,                       /* WWWWBBBB WWWWBBBB */
0xf0,0xf0,                       /* WWWWBBBB WWWWBBBB */
0xf0,0xf0,                       /* WWWWBBBB WWWWBBBB */
0xf0,0xf0,                       /* WWWWBBBB WWWWBBBB */
0x0f,0x0f,                       /* BBBBWWWW BBBBWWWW */
0x0f,0x0f,                       /* BBBBWWWW BBBBWWWW */
0x0f,0x0f,                       /* BBBBWWWW BBBBWWWW */
0x0f,0x0f,                       /* BBBBWWWW BBBBWWWW */
};
输出样例
16
QQWBBWQWBBWQWBBWQWBBW
提示
Since the problems "Quadtree" and "Quadtree II" are inverse to each other, you can double check your programs by converting back and forth between the respective input and output files.

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

题目来源 Ulm Local 1999

源链接: POJ-2270

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

共提交 0

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