#abc339b. B - Langton's Takahashi

B - Langton's Takahashi

Score: 250250 points

问题描述

存在一个 HH 行和 WW 列的网格;最初,所有单元格都被涂成白色。令 (i,j)(i, j) 表示从上到下的第 ii 行以及从左到右的第 jj 列的单元格。

这个网格被认为是环面的。也就是说,对于每个 1iH1 \leq i \leq H(i,1)(i, 1)(i,W)(i, W) 的右侧,并且对于每个 1jW1 \leq j \leq W(1,j)(1, j)(H,j)(H, j) 的下方。

高桥位于 (1,1)(1, 1) 处并面向上方。在高桥重复执行以下操作 NN 次后,打印网格中每个单元格的颜色。

  • 如果当前单元格被涂成白色,则将其重新涂成黑色,顺时针旋转 9090^\circ,然后按照他面对的方向向前移动一格。否则,将当前单元格重新涂成白色,逆时针旋转 9090^\circ,然后按照他面对的方向向前移动一格。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There is a grid with HH rows and WW columns; initially, all cells are painted white. Let (i,j)(i, j) denote the cell at the ii-th row from the top and the jj-th column from the left.

This grid is considered to be toroidal. That is, (i,1)(i, 1) is to the right of (i,W)(i, W) for each 1iH1 \leq i \leq H, and (1,j)(1, j) is below (H,j)(H, j) for each 1jW1 \leq j \leq W.

Takahashi is at (1,1)(1, 1) and facing upwards. Print the color of each cell in the grid after Takahashi repeats the following operation NN times.

  • If the current cell is painted white, repaint it black, rotate 9090^\circ clockwise, and move forward one cell in the direction he is facing. Otherwise, repaint the current cell white, rotate 9090^\circ counterclockwise, and move forward one cell in the direction he is facing.

Constraints

  • 1H,W1001 \leq H, W \leq 100
  • 1N10001 \leq N \leq 1000
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

HH WW NN

Output

Print HH lines. The ii-th line should contain a string of length WW where the jj-th character is . if the cell (i,j)(i, j) is painted white, and # if it is painted black.

Sample Input 1

3 4 5

Sample Output 1

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

The cells of the grid change as follows due to the operations:

....   #...   ##..   ##..   ##..   .#..
.... → .... → .... → .#.. → ##.. → ##..
....   ....   ....   ....   ....   ....

Sample Input 2

2 2 1000

Sample Output 2

..
..

Sample Input 3

10 10 10

Sample Output 3

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

update @ 2024/3/10 01:30:56