Codeforces Beta Round #7 A. Kalevitch and Chess 水题
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 水题的更多相关文章
- 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. ...
- Codeforces Beta Round #97 (Div. 1) A. Replacement 水题
A. Replacement 题目连接: http://codeforces.com/contest/135/problem/A Description Little Petya very much ...
- Codeforces Beta Round #10 A. Power Consumption Calculation 水题
A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- 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]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
随机推荐
- mysq配置
mysql运维 1.mysql配置文件:/etc/my.cnf mysql日记文件 :安装时候配置的,可以通过ps aux|grep mysqld 查询 ps aux|grep mysqld mysq ...
- 用C#实现对MSSqlServer数据库的增删改查---Server层(WaterLevelSetServer.cs、DeviceSetServer.cs)
在Server层定义WaterLevelSetServer和WaterLevelRecordServer两个子类,分别继承DeviceSetServer和DeviceRecordServer. usi ...
- 大数据系列之Kafka安装
先简单说下安装kafka的流程..(可配置多个zookeeper,这篇文只说一个zookeeper场景) 1.环境配置:jdk1.7+ (LZ用的是jdk1.8) 2.资料准备:下载 kafka_2. ...
- Redis 启动与授权
启动 Redis $redis-server 检查Redis是否在工作? $redis-cli 这将打开一个Redis提示,如下图所示: redis 127.0.0.1:6379> 上面的提示1 ...
- php将长字符串拆分为指定最大宽度的字符串数组
/** * 将字符串拆分为指定最大宽度的字符串数组.单字节字符宽度为1,多字节字符通常宽度为2 * @param string $msg 要拆分的字符串 * @param int $width 结果数 ...
- bzoj 1853 容斥 + 搜索
思路:先把所有幸运数字找出来, 把没有用的去掉,然后爆搜容斥,因为最多只会搜十几个就超过限制了, 所以是可行的. #include<bits/stdc++.h> #define LL lo ...
- (转)Where与Having的总结
Where 是一个约束声明,使用Where来约束来之数据库的数据,Where是在结果返回之前起作用的,且Where中不能使用聚合函数. Having 是一个过滤声明,是在查询返回结果集以后对查询结果进 ...
- pip安装报错解决
使用pip安装docker-compose时报 unsupported operand type(s) for -=: 'Retry' and 'int' 错误,经过一番google后,发现使用升级s ...
- 为什么ArrayList remove报错
不报错 List<String> userNames = new ArrayList<String>() {{ add("Hollis"); add(&qu ...
- ssm demo,用户角色权限管理
SSM框架整合 Spring SpringMVC MyBatis 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastjson 5, aspectwea ...