問題一覧 > 通常問題

No.712 Red Flag

レベル : / AI推定難易度 : 75 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 525
作問者 : kyamatsu / テスター : butsurizuki
お気に入りにしたユーザー ProblemId : 1168 / 自分の提出
問題文最終更新日: 2026-06-25 23:34:51
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 195 (順位表) の他の問題:

Problem Statement

K, whose hobby is studying communist and socialist countries, has decided to make a flag to decorate a booth at the Ohashi Technical College cultural festival.

The flag is divided into a grid of N rows and M columns.

He wants to paint the entire flag red.
However, an arbitrary number of arbitrary cells of the flag have already been painted red.
How many cells need to be painted in order to make all cells of the flag red?

Input

$N\ M$
$A_1$
$\dots$
$A_N$

The first line contains two integers N, M (3 ≦ N ≦ 50, 3 ≦ M ≦ 50) separated by a space. This means that the flag is divided into a grid of N rows and M columns.

Each of the following N lines contains a string of M characters, representing the colors painted on the cells of the flag. The j-th character (1 ≦ j ≦ M) of the i-th of these N lines (1 ≦ i ≦ N) is either 'W' or 'R', representing the color of the cell at row i, column j of the old flag's grid. 'W' represents white and 'R' represents red.

Output

Output a single line.
Output the minimum number of cells that must be painted in order to make all cells of the NxM flag red.

Sample

Sample 1
Input
3 3
WRW
RWR
WRW
Output
5

Sample 2
Input
8 5
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR
Output
0

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