A - Three Cells per Row and Column 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 300

問題文

NN 列からなる盤面があります.

以下の条件をすべて満たすように,すべてのマスを白か黒で塗ってください.

  • 各行について,その行のマスのうちちょうど 3 個が黒く塗られている.
  • 各列について,その列のマスのうちちょうど 3 個が黒く塗られている.
  • 黒いマスからなる連結成分の個数がちょうど N 個である. ここで,ある 2 つの黒いマス x,y が連結であるとは,x からスタートし,上下左右の黒いマスに移動することを繰り返し,y に到達できることを意味する.

なお,問題の制約より,必ず解が存在することが証明できます.

制約

  • 6 \leq N \leq 500
  • 入力される値はすべて整数である

入力

入力は以下の形式で標準入力から与えられる.

N

出力

答えを以下の形式で出力せよ.

s_{1,1}s_{1,2}\cdots s_{1,N}
s_{2,1}s_{2,2}\cdots s_{2,N}
\vdots
s_{N,1}s_{N,2}\cdots s_{N,N}

ここで,s_{i,j} は,上から i 行目,左から j 列目のマスを塗る色を表す文字であり, s_{i,j}=# のときはそのマスを黒く,s_{i,j}=. のときはそのマスを白く塗ることを意味する. 答えが複数存在する場合,どれを出力しても正解とみなされる.


入力例 1

6

出力例 1

##..#.
##..#.
..##.#
..##.#
##...#
..###.

各行,各列にある # の個数はちょうど 3 です. また,# からなる連結成分の個数はちょうど 6 です.

Score : 300 points

Problem Statement

We have a grid board with N rows and N 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 N connected components of black squares. Here, two black squares x and y are considered connected when it is possible to start at x and reach y 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

  • 6 \leq N \leq 500
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Print your answer in the following format:

s_{1,1}s_{1,2}\cdots s_{1,N}
s_{2,1}s_{2,2}\cdots s_{2,N}
\vdots
s_{N,1}s_{N,2}\cdots s_{N,N}

Here, s_{i,j} should be a character representing the color of the square at the i-th row from the top and j-th column from the left: s_{i,j}=# means the square is painted black, and s_{i,j}=. means it is painted white. If multiple solutions exist, printing any of them is accepted.


Sample Input 1

6

Sample Output 1

##..#.
##..#.
..##.#
..##.#
##...#
..###.

Here, there are exactly 3 #s in each row and column. Additionally, there are exactly 6 connected components of #s.