問題一覧 > 通常問題

No.2432 Flip and Move

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 48
作問者 : tassei903 / テスター : noya2 👑 potato167 ponjuice
お気に入りにしたユーザー ProblemId : 9918 / 自分の提出
問題文最終更新日: 2023-08-14 18:16:33
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
traP 作問ハッカソンコンテスト 001 (順位表) の他の問題:

Problem Statement

There is an $H \times W$ grid, and each cell is painted either white or black. The cell in the $i$-th row from the top and the $j$-th column from the left is denoted by $(i,j)$.
By operating a recoloring robot placed on this grid some number of times, the colors of the cells change.

The state of the robot consists of its current cell, its vertical direction (up or down), and its horizontal direction (left or right).
The robot cannot move outside the grid.

In $1$ operation, the robot performs the following actions in order.

  • Flip the color of the current cell. (White becomes black, and black becomes white.)
  • If it can move $1$ cell in its current vertical direction, it moves $1$ cell. If it cannot, it reverses its vertical direction and stays in that cell.
  • If it can move $1$ cell in its current horizontal direction, it moves $1$ cell. If it cannot, it reverses its horizontal direction and stays in that cell.

Initially, all cells are painted white, the robot is placed on cell $(1, 1)$, its vertical direction is down, and its horizontal direction is right.

When the robot is operated $K$ times, find the final color of each cell.

Input

$H\ W$
$K$

  • $1 \le H$
  • $1 \le W$
  • $H \times W \le 10^6$
  • $1 \le K \le 10^{18}$
  • All inputs are integers.

Output

Let $S_{i, j}$ denote the color of cell $(i, j)$, where $S_{i, j} =$ . if it is white and $S_{i, j} =$ # if it is black.
Output in the following format.
$S_{1,1} S_{1,2}\ldots S_{1,W}$
$S_{2,1} S_{2,2}\ldots S_{2,W}$
$\vdots$
$S_{H,1} S_{H,2}\ldots S_{H,W}$

Sample

Sample 1
Input
2 3
4
Output
#.#
.##

The robot flips the colors of cells $(1, 1)$, $(2, 2)$, $(2, 3)$, $(1, 3)$ in this order.

Sample 2
Input
2 2
3
Output
#.
..

The robot flips the colors of cells $(1, 1)$, $(2, 2)$, $(2, 2)$ in this order.

Sample 3
Input
11 7
1024
Output
###..##
##.##.#
#.####.
.#####.
.####.#
#.##.##
##..###
##..###
#.##.##
.####.#
..####.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。