103346: [Atcoder]ABC334 G - Christmas Color Grid 2

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $650$ points

Problem Statement

This problem has a similar setting to Problem E. Differences in the problem statement are indicated in red.

There is a grid with $H$ rows and $W$ columns, where each cell is painted red or green.

Let $(i,j)$ denote the cell in the $i$-th row from the top and the $j$-th column from the left.

The color of cell $(i,j)$ is represented by the character $S_{i,j}$, where $S_{i,j} =$ . means cell $(i,j)$ is red, and $S_{i,j} =$ # means cell $(i,j)$ is green.

The number of green connected components in the grid is the number of connected components in the graph with the vertex set being the green cells and the edge set being the edges connecting two adjacent green cells. Here, two cells $(x,y)$ and $(x',y')$ are considered adjacent when $|x-x'| + |y-y'| = 1$.

Consider choosing one green

Input

Output

分数:$650$分

问题描述

此问题与问题E具有类似的设置。问题描述中的差异用红色表示。

有一个包含$H$行和$W$列的网格,其中每个单元格都涂成红色或绿色。

让$(i,j)$表示从顶部数第$i$行,从左边数第$j$列的单元格。

单元格$(i,j)$的颜色由字符$S_{i,j}$表示,其中$S_{i,j} =$ .表示单元格$(i,j)$是红色,$S_{i,j} =$ #表示单元格$(i,j)$是绿色。

网格中的绿色连通分量的数量是指以绿色单元格为顶点集,以连接两个相邻绿色单元格的边为边集的图中的连通分量的数量。在这里,当$|x-x'| + |y-y'| = 1$时,两个单元格$(x,y)$和$(x',y')$被认为是相邻的。

考虑选择一个绿色

加入题单

算法标签: