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?
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
Note: The comments (enclosed by /* and */) are not part of the input. They should help to explain the XBM format.