問題一覧 > 通常問題

No.459 C-VS for yukicoder

レベル : / AI推定難易度 : 1250 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 59
作問者 : mai / テスター : tubo28
お気に入りにしたユーザー ProblemId : 1435 / 自分の提出
問題文最終更新日: 2025-02-10 00:21:00
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
Advent Calendar Contest 2016 (順位表) の他の問題:

Note

This problem was created as the problem for day 10 of Advent Calendar Contest Advent Calendar 2016.
Thank you all for codevs! (2016/12/10)

Problem Statement

Mai is participating in a game AI contest called c-vs.


What is c-vs?

It is a so-called "Puyo Puyo-style game" in which given packs (clusters of height 3 and width 3 containing at least one block) are dropped onto a field of height $H$ and width $W$.
Blocks are supposed to be cleared through chains, but due to the circumstances described below, the game consists only of dropping.

The game c-vs proceeds according to the following flow.

  1. A pack is given, and the player decides its drop position.
    The position can be specified as an integer in the range from $0$ to $W-3$, where $0$ is the left end and $W-3$ is the position moved 2 to the left from the right end. Rotation is not allowed.
  2. The left end of the pack is aligned to the chosen drop position, and the pack is dropped at that position.
  3. Blocks fall until there is a floor below them or they hit a stacked block.
  4. The flow from 1 to 3 is one turn. This is repeated.

Mai was matched with Maiba, and the game started.

However, at the very moment the game started, Maiba entered a special command, so all blocks contained in the packs falling onto the field were painted black.
Now it is impossible to clear blocks through chains.

Mai specified $C_i$ as the drop position of the pack on turn $i$ ($1 \le i \le N$). As a result, the state of the field at the point when step 3. of turn $N$ finished was $S$.


What packs were given? Find the contents of the $N$ packs given to Mai.

Input

$H$ $W$ $N$
$S_1$
$S_2$
...
$S_H$
$C_1$
$C_2$
$...$
$C_N$

All of the following constraints are satisfied simultaneously.
$3 \le W \le 10000$
$1 \le H \le 10000$
$3 \le H \times W \le 30000$
$1 \le N \le \min \{ H \times W , 30000 \}$
$|S_i| = W$
$S_i$ is a string consisting of '.' and '#', and contains at least one '#'.
$0 \le C_i \le W-3$
All numbers given are integers.

The field state $S$ is represented by $H$ strings $S_1,S_2,...,S_H$.
The field cell that is $x$-th from the left and $y$-th from the top corresponds to the $x$-th character from the left of the string $S_y$;
'#' means that a block exists in that cell, and '.' means that it is empty.

The given field state is limited to those obtainable by a game progression that satisfies the statement.

Output

Output $N$ packs separated by newlines according to the following format. That is, output $3 \times N$ lines.
The $i$-th pack from the top must correspond to $C_i$.

A pack is represented by strings of 3 lines with 3 characters each.
The cell of the pack that is $y$-th from the top and $x$-th from the left corresponds to the $x$-th character of line $y$,
which is '.' if the cell is empty and '#' if a block exists in it.

As stated in the problem statement, note that every pack must have at least one block.

Print a newline at the end.


A special judge written in c++14 is used.
There may be more than one solution, but any of them will be judged AC.

Sample

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

The sample output is one of the solutions; as long as the requirements are met, your output will be judged AC even if it does not match this output.

Sample 2
Input
3 3 2
###
###
###
0
0
Sample Output
...
...
#..
.##
###
###

Do not output a pack that has no blocks.

Sample 3
Input
4 11 5
....#......
##.##..##..
##.###.####
######.####
0
2
4
6
8
Sample Output
##.
##.
##.
.##
.##
###
...
.#.
##.
.#.
.##
.##
...
.##
###

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