#abc309b. B - Rotate
B - Rotate
Score : points
问题描述
你将获得一个 行和 列的网格。在从上数第 行、从左数第 列的位置上写有一个整数 。这里保证 是 或者 。
将位于外层方格上的整数按顺时针方向各向右移动一位,然后输出变换后的网格。
这里的外层方格指的是至少位于第一行、第 行、第一列或第 列中的方格。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a grid with rows and columns. An integer is written on the square at the -th row from the top and -th column from the left. Here, it is guaranteed that is either or .
Shift the integers written on the outer squares clockwise by one square each, and print the resulting grid.
Here, the outer squares are those in at least one of the -st row, -th row, -st column, and -th column.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Let be the integer written on the square at the -th row from the top and -th column from the left in the grid resulting from shifting the outer squares clockwise by one square each. Print them in the following format:
Sample Input 1
4
0101
1101
1111
0000
Sample Output 1
1010
1101
0111
0001
We denote by the square at the -th row from the top and -th column from the left.
The outer squares, in clockwise order starting from , are the following squares: $(1,1),(1,2),(1,3),(1,4),(2,4),(3,4),(4,4),(4,3),(4,2),(4,1),(3,1)$, and .
The sample output shows the resulting grid after shifting the integers written on those squares clockwise by one square.
Sample Input 2
2
11
11
Sample Output 2
11
11
Sample Input 3
5
01010
01001
10110
00110
01010
Sample Output 3
00101
11000
00111
00110
10100
update @ 2024/3/10 08:45:49