CF7A.Kalevitch and Chess
普及-
通过率:0%
时间限制:2.00s
内存限制:64MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch decided to put an end to this tradition and to introduce a new attitude to chessboards.
As before, the chessboard is a square-checkered board with the squares arranged in a 8 × 8 grid, each square is painted black or white. Kalevitch suggests that chessboards should be painted in the following manner: there should be chosen a horizontal or a vertical line of 8 squares (i.e. a row or a column), and painted black. Initially the whole chessboard is white, and it can be painted in the above described way one or more times. It is allowed to paint a square many times, but after the first time it does not change its colour any more and remains black. Kalevitch paints chessboards neatly, and it is impossible to judge by an individual square if it was painted with a vertical or a horizontal stroke.
Kalevitch hopes that such chessboards will gain popularity, and he will be commissioned to paint chessboards, which will help him ensure a comfortable old age. The clients will inform him what chessboard they want to have, and the painter will paint a white chessboard meeting the client's requirements.
It goes without saying that in such business one should economize on everything — for each commission he wants to know the minimum amount of strokes that he has to paint to fulfill the client's needs. You are asked to help Kalevitch with this task.
著名的贝尔兰画家卡列维奇喜欢震惊公众。他最近的痴迷之一是国际象棋。一千多年来,人们一直在单调乏味的棋盘上玩这种古老的游戏。卡列维奇决定终结这一传统,为国际象棋棋盘引入一种全新的风格。
与以往一样,国际象棋棋盘是一个由方格组成的正方形棋盘,方格排列成 8×8 的网格,每个方格被涂成黑色或白色。卡列维奇建议,棋盘应按如下方式着色:选择一行(即水平方向的 8 个方格)或一列(即垂直方向的 8 个方格),并将该整行或整列涂成黑色。初始时整个棋盘为白色,且可按上述方式重复涂色一次或多次。允许对方格多次涂色,但第一次涂黑后其颜色不再改变,始终保持黑色。卡列维奇作画十分工整,因此仅凭单个方格无法判断它是被水平笔画还是垂直笔画涂黑的。
卡列维奇希望此类棋盘能广受欢迎,从而为自己赢得大量订单,助他安享晚年。客户会向他说明所需棋盘的具体样式,画家则需在一块白色棋盘上完成符合客户要求的涂色。
毋庸置疑,在这类生意中必须精打细算——对每一份订单,他都希望知道满足客户需求所需的最少涂色次数。你需要帮助卡列维奇完成这项任务。
输入格式
The input file contains 8 lines, each of the lines contains 8 characters. The given matrix describes the client's requirements, W character stands for a white square, and B character — for a square painted black.
It is guaranteed that client's requirments can be fulfilled with a sequence of allowed strokes (vertical/column or horizontal/row).
输入文件包含 8 行,每行包含 8 个字符。给定的矩阵描述了客户的需求,其中字符 W 表示白色方格,字符 B 表示黑色方格。
保证客户的需求可以通过一系列允许的操作(垂直/列方向或水平/行方向的涂色)来满足。
输出格式
Output the only number — the minimum amount of rows and columns that Kalevitch has to paint on the white chessboard to meet the client's requirements.
输出唯一的一个数字——Kalevitch 为满足客户要求,需要在白色棋盘上涂色的最少行数与列数之和。
输入输出样例
输入#1
WWWBWWBW BBBBBBBB WWWBWWBW WWWBWWBW WWWBWWBW WWWBWWBW WWWBWWBW WWWBWWBW
输出#1
3
输入#2
WWWWWWWW BBBBBBBB WWWWWWWW WWWWWWWW WWWWWWWW WWWWWWWW WWWWWWWW WWWWWWWW
输出#2
1
输入解题思路,AI测评打分。不知道怎么写?