atcoder#AGC056A. [AGC056A] Three Cells per Row and Column
[AGC056A] Three Cells per Row and Column
Score : points
Problem Statement
We have a grid board with rows and columns.
Paint every square black or white to satisfy all of the conditions below.
- For each row, exactly three of the squares in that row are painted black.
- For each column, exactly three of the squares in that column are painted black.
- There are exactly connected components of black squares. Here, two black squares and are considered connected when it is possible to start at and reach by repeatedly moving up, down, left, or right to a black square.
It can be proved that the Constraints of the problem guarantee the existence of a solution.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print your answer in the following format:
Here, should be a character representing the color of the square at the -th row from the top and -th column from the left: #
means the square is painted black, and .
means it is painted white.
If multiple solutions exist, printing any of them is accepted.
6
##..#.
##..#.
..##.#
..##.#
##...#
..###.
Here, there are exactly #
s in each row and column.
Additionally, there are exactly connected components of #
s.