#abc375c. C - Spiral Rotation
C - Spiral Rotation
Score : points
问题陈述
你有一个 行 列的网格,其中 是一个偶数。用 表示从顶部数第 行和从左边数第 列的单元格。
每个单元格被涂成黑色或白色。如果 #
,单元格 是黑色的;如果 .
,它是白色的。
在按照 的顺序执行以下操作后,找出每个单元格的颜色。
- 对于所有在 和 之间的整数对 (包括 和 ),将单元格 的颜色替换为单元格 的颜色。对于所有这样的整数对 ,同时执行这些替换。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a grid with rows and columns, where is an even number. Let denote the cell at the -th row from the top and -th column from the left.
Each cell is painted black or white. If #
, cell is black; if .
, it is white.
Find the color of each cell after performing the following operation for in this order.
- For all pairs of integers between and , inclusive, replace the color of cell with the color of cell . Perform these replacements simultaneously for all such pairs .
Constraints
- is an even number between and , inclusive.
- Each is
#
or.
.
Input
The input is given from Standard Input in the following format:
Output
After all operations, let #
if cell is black, and .
if it is white. Print the grid in the following format:
Sample Input 1
8
.......#
.......#
.####..#
.####..#
.##....#
.##....#
.#######
.#######
Sample Output 1
........
#######.
#.....#.
#.###.#.
#.#...#.
#.#####.
#.......
########
The operations change the colors of the grid cells as follows:
.......# ........ ........ ........ ........
.......# ######.. #######. #######. #######.
.####..# ######.. #....##. #.....#. #.....#.
.####..# → ##..##.. → #....##. → #.##..#. → #.###.#.
.##....# ##..##.. #..####. #.##..#. #.#...#.
.##....# ##...... #..####. #.#####. #.#####.
.####### ##...... #....... #....... #.......
.####### ######## ######## ######## ########
Sample Input 2
6
.#.#.#
##.#..
...###
###...
..#.##
#.#.#.
Sample Output 2
#.#.#.
.#.#.#
#.#.#.
.#.#.#
#.#.#.
.#.#.#
Sample Input 3
12
.......#.###
#...#...#..#
###.#..#####
..#.#.#.#...
.#.....#.###
.......#.#..
#...#..#....
#####.......
...#...#.#.#
..###..#..##
#..#.#.#.#.#
.####.......
Sample Output 3
.#..##...##.
#.#.#.#.#...
###.##..#...
#.#.#.#.#...
#.#.##...##.
............
............
.###.###.###
...#...#.#..
.###...#.###
...#...#...#
.###...#.###