問題一覧 > 通常問題

No.2946 Puyo

レベル : / AI推定難易度 : 600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 138
作問者 : Michirakara / テスター : rotti_coder nouka28 t9unkubj
お気に入りにしたユーザー ProblemId : 10811 / 自分の提出
問題文最終更新日: 2024-10-25 10:57:03
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
yukicoder contest 451 (並木中等プログラミングコンテスト 2024) (順位表) の他の問題:

Problem Statement

You are given a grid $G$ with $H$ rows and $W$ columns consisting of uppercase English letters and ..

For every connected component of size $4$ or greater, simultaneously replace all cells belonging to it with ., and output the resulting grid.

Notes

Cells $c_1,c_2$ are connected if it is possible to get from cell $c_1$ to cell $c_2$ by repeatedly moving to a vertically or horizontally adjacent cell on which the same character is written.

A set of cells $S$ is a connected component if $S$ satisfies the following conditions.

  • Any $2$ cells in $S$ are connected.
  • No cell not contained in $S$ is connected to a cell contained in $S$.

Constraints

  • $1\leq H\leq 1000$
  • $1\leq W\leq 1000$
  • $G_{i,j}(1\leq i\leq H, 1\leq j\leq W)$ is an uppercase English letter or .

Input

$H\ W$
$G_{1,1}\ G_{1,2}\ \dots\ G_{1,W}$
$G_{2,1}\ G_{2,2}\ \dots\ G_{2,W}$
$\vdots$
$G_{H,1}\ G_{H,2}\ \dots\ G_{H,W}$

Output

Output the resulting grid with $H$ rows and $W$ columns after the replacement.
Print a newline at the end.

Sample

Sample 1
Input
4 4
AAAA
ABCB
ADDA
AEEE
Output
....
.BCB
.DDA
.EEE

Note that parts that are not connected are not replaced, even if they have the same character.

Sample 2
Input
1 1
.
Output
.

Note that the input may contain ..

Sample 3
Input
3 3
ABB
A.B
AAB
Output
...
...
...

All clear!

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