#P7049. Jury's Artistic Panel
Jury's Artistic Panel
Jury's Artistic Panel
The jury has a great artistic idea – to create a rectangular panel out of a huge pile of black and white squares of the same size. The panel should have exactly \(b\) 4-connected areas made of black tiles, and \(w\) 4-connected areas made of white tiles.
Recall that a 4-connected area of a particular color is a maximal set of tiles of that color such that any two tiles in the area can be connected by a sequence of moves, each move going to a tile sharing a common side.
Your task is to output a valid panel design that satisfies the requirements. The panel is represented by a grid, where each cell is either a black tile (denoted by the character '#' ) or a white tile (denoted by the character '.' ).
The output panel must obey the following rules:
- The first line of the output should contain two integers \(H\) and \(W\), the height and width of the panel.
- Then follow \(H\) lines, each containing \(W\) characters that are either '#' or '.'.
- The panel must have exactly \(b\) 4-connected black areas and exactly \(w\) 4-connected white areas.
It is guaranteed that \(b\) and \(w\) are positive integers. A common constructive approach is to start by dividing the grid into two halves: one entirely filled with black and the other entirely filled with white. Then, isolated islands of the opposite color are added in each half to increase the number of connected areas. Any valid panel design satisfying the condition will be accepted.
inputFormat
The input consists of a single line with two integers \(b\) and \(w\) (both \(\ge 1\)). \(b\) denotes the required number of black 4-connected areas, and \(w\) denotes the required number of white 4-connected areas.
outputFormat
Output a valid panel design. The first line should contain two integers \(H\) and \(W\) representing the height and width of the panel. Then output \(H\) lines, each containing \(W\) characters where '#' represents a black tile and '.' represents a white tile. The design must have exactly \(b\) black 4-connected areas and \(w\) white 4-connected areas.
sample
1 1
A valid panel design (for instance, a 100x100 grid with the top half black and bottom half white, with no added islands) where there is 1 black connected component and 1 white connected component.