

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
概要:以下のような N\times N の模様を作成してください。########### #.........# #.#######.# #.#.....#.# #.#.###.#.# #.#.#.#.#.# #.#.###.#.# #.#.....#.# #.#######.# #.........# ###########
正整数 N が与えられます。
N\times N のグリッドがあります。このグリッドの上から i 行目、左から j 列目のマスをマス (i,j) と表します。はじめ、どのマスにも色は塗られていません。
これから、i=1,2,\dots,N の順に、以下の操作を行います。
- j=N+1-i とする。
- i\leq j であるならば、i が奇数ならば黒、偶数ならば白で、マス (i,i) を左上、マス (j,j) を右下とする矩形領域に含まれるマスを塗りつぶす。このとき、既に色が塗られているマスについては色を上書きする。
- i\gt j であるならば、何もしない。
すべての操作を行った後、色が塗られていないマスが存在しないことが証明できます。最終的に各マスがどの色で塗られているかを求めてください。
制約
- 1\leq N\leq 50
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
N 行出力せよ。i 行目には、最終的にグリッドの i 行目に塗られている色を以下のような長さ N の文字列 S_i として出力せよ。入出力例も参考にすること。
- マス (i,j) が最終的に黒で塗られているならば、S_i の j 文字目は
#
である。 - マス (i,j) が最終的に白で塗られているならば、S_i の j 文字目は
.
である。
入力例 1
11
出力例 1
########### #.........# #.#######.# #.#.....#.# #.#.###.#.# #.#.#.#.#.# #.#.###.#.# #.#.....#.# #.#######.# #.........# ###########
概要で示した模様と同じです。
入力例 2
5
出力例 2
##### #...# #.#.# #...# #####
以下のように色が塗られます。ここで、まだ色が塗られていないマスを ?
と表します。
i=1 i=2 i=3 i=4 i=5 ????? ##### ##### ##### ##### ##### ????? ##### #...# #...# #...# #...# ????? -> ##### -> #...# -> #.#.# -> #.#.# -> #.#.# ????? ##### #...# #...# #...# #...# ????? ##### ##### ##### ##### #####
入力例 3
8
出力例 3
######## #......# #.####.# #.#..#.# #.#..#.# #.####.# #......# ########
入力例 4
2
出力例 4
## ##
Score : 200 points
Problem Statement
Overview: Create an N \times N pattern as follows.########### #.........# #.#######.# #.#.....#.# #.#.###.#.# #.#.#.#.#.# #.#.###.#.# #.#.....#.# #.#######.# #.........# ###########
You are given a positive integer N.
Consider an N \times N grid. Let (i,j) denote the cell at the i-th row from the top and the j-th column from the left. Initially, no cell is colored.
Then, for i = 1,2,\dots,N in order, perform the following operation:
- Let j = N + 1 - i.
- If i \leq j, fill the rectangular region whose top-left cell is (i,i) and bottom-right cell is (j,j) with black if i is odd, or white if i is even. If some cells are already colored, overwrite their colors.
- If i > j, do nothing.
After all these operations, it can be proved that there are no uncolored cells. Determine the final color of each cell.
Constraints
- 1 \leq N \leq 50
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N
Output
Print N lines. The i-th line should contain a length-N string S_i representing the colors of the i-th row of the grid after all operations, as follows:
- If cell (i,j) is finally colored black, the j-th character of S_i should be
#
. - If cell (i,j) is finally colored white, the j-th character of S_i should be
.
.
Sample Input 1
11
Sample Output 1
########### #.........# #.#######.# #.#.....#.# #.#.###.#.# #.#.#.#.#.# #.#.###.#.# #.#.....#.# #.#######.# #.........# ###########
This matches the pattern shown in the Overview.
Sample Input 2
5
Sample Output 2
##### #...# #.#.# #...# #####
Colors are applied as follows, where ?
denotes a cell not yet colored:
i=1 i=2 i=3 i=4 i=5 ????? ##### ##### ##### ##### ##### ????? ##### #...# #...# #...# #...# ????? -> ##### -> #...# -> #.#.# -> #.#.# -> #.#.# ????? ##### #...# #...# #...# #...# ????? ##### ##### ##### ##### #####
Sample Input 3
8
Sample Output 3
######## #......# #.####.# #.#..#.# #.#..#.# #.####.# #......# ########
Sample Input 4
2
Sample Output 4
## ##