Black and White Panel
Time limit2sMemory limit256 MB
Print the fixed 101-column black and white grid whose isolated single tiles yield exactly b black areas and w white areas.
- Level
Easy2 of 10
- Topics
- Implementation, Matrix
- Solved
- No attempts yet
Problem
You build a rectangular panel out of black and white square tiles of the same size. The finished panel must contain exactly 4-connected areas of black tiles and exactly 4-connected areas of white tiles.
A 4-connected area of one color is a maximal set of tiles that satisfies both conditions below.
- All tiles of the set have the same color.
- For any two tiles of the set there is a sequence of tiles of the set connecting them, and consecutive tiles of the sequence share a side.
Many panels meet these counts, so only the panel fixed by the output rule below is accepted.
Input
The first line contains the number of black areas and the number of white areas . ()
Output
Print the number of rows and the number of columns of the panel on the first line, then print lines of characters each. A black tile is @ and a white tile is ..
The accepted panel is fixed by the rule below. Rows and columns are numbered from 1.
- Let and .
- The panel always has columns.
- The top black block has height , the bottom white block has height , and .
- Rows through form the top block and start out all
@. For each , change the tile in row and column to.. - Rows through form the bottom block and start out all
.. For each , change the tile in row and column to@.