A. Kalevitch and Chess

题目连接:

http://www.codeforces.com/contest/7/problem/A

Description

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.

Input

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).

Output

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.

Sample Input

WWWBWWBW

BBBBBBBB

WWWBWWBW

WWWBWWBW

WWWBWWBW

WWWBWWBW

WWWBWWBW

WWWBWWBW

Sample Output

3

Hint

题意

给你一个8*8的矩阵,一开始全是白色的

然后你有一个刷子,可以把某一行或者某一列刷成黑色

问你最少刷多少发。

题解:

某一行全是B,那么就横着刷,否则就竖着刷嘛

然后就完了……

代码

#include<bits/stdc++.h>
using namespace std; string s;
int vis[10][10];
int main()
{
int ans1=0,ans2=10;
for(int i=1;i<=8;i++)
{
cin>>s;
int add = 0;
for(int j=0;j<8;j++)
if(s[j]=='B')add++;
if(add==8)ans1++;
ans2=min(ans2,add);
}
if(ans1==8)cout<<8<<endl;
else cout<<ans1+ans2<<endl;
}

Codeforces Beta Round #7 A. Kalevitch and Chess 水题的更多相关文章

  1. Codeforces Beta Round #14 (Div. 2) A. Letter 水题

    A. Letter 题目连接: http://www.codeforces.com/contest/14/problem/A Description A boy Bob likes to draw. ...

  2. Codeforces Beta Round #97 (Div. 1) A. Replacement 水题

    A. Replacement 题目连接: http://codeforces.com/contest/135/problem/A Description Little Petya very much ...

  3. Codeforces Beta Round #10 A. Power Consumption Calculation 水题

    A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...

  4. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  5. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  6. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  7. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  8. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  9. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

随机推荐

  1. php常用函数——字符串函数

    php常用函数——字符串函数

  2. linux 查看内存和cpu占用比较多的进程

    1.可以使用一下命令查使用内存最多的10个进程        ps -aux | sort -k4nr | head -n 102. 可以使用一下命令查使用CPU最多的10个进程        ps ...

  3. FPGA编码规则检查表

    FPGA编码规则检查表 -----------------------摘自<FPGA软件测试与评价技术> 中国电子信息产业发展研究院 | 编著 1.一个单独的文件应该只包含一个单独的mod ...

  4. 认识Cookie和状态管理

    HTTP协议是一种无状态的协议,WEB服务器本身不能识别出哪些请求是同一个浏览器发出的 ,浏览器的每一次请求都是完全孤立的 即使 HTTP1.1 支持持续连接,但当用户有一段时间没有提交请求,连接也会 ...

  5. Machine Learning系列--EM算法理解与推导

    EM算法,全称Expectation Maximization Algorithm,译作最大期望化算法或期望最大算法,是机器学习十大算法之一,吴军博士在<数学之美>书中称其为“上帝视角”算 ...

  6. 读书笔记 effective c++ Item 4 确保对象被使用前进行初始化

    C++在对象的初始化上是变化无常的,例如看下面的例子: int x; 在一些上下文中,x保证会被初始化成0,在其他一些情况下却不能够保证.看下面的例子: class Point { int x,y; ...

  7. 最小的Django应用

    创建一个hello.py   内容如下: import sys from django.conf import settings # 设置 settings.configure( DEBUG = Tr ...

  8. 5、SourceTree使用git

    1.拉取分支 拉去分支请参见:3.SourceTree通过PUTTY连接GitLab 最后内容 注:如果拉取后看不见master,请在gitLab页面的master上新建一个文件即可. 2.创建一个分 ...

  9. python爬取网易云音乐歌单音乐

    在网易云音乐中第一页歌单的url:http://music.163.com/#/discover/playlist/ 依次第二页:http://music.163.com/#/discover/pla ...

  10. Effective STL 阅读笔记: Item 4 ~ 5: Call empty instead of checking size() against zero.

    Table of Contents 1 Item 4: Call empty instead of checking size() against zero 2 Item 5: Prefer rang ...