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 ...
随机推荐
- discuz 积分按日重新计算,(摒弃以前24小时计算)
修改\source\module\forum\forum_misc.php将 foreach(C::t('forum_ratelog')->fetch_all_sum_score($_G['ui ...
- Android上HDMI介绍(基于高通平台)
本文重点针对HDMI在android上的应用,而比较相关的就是overlay机制.overlay在这里只是简单的介绍,后续会有文章再专门详述. 我没记错的话,高通从7X30开始,平台就可以支持HDMI ...
- 「pycaffe指南」使用caffe的NetSpec.py中的Python接口自动生成×.prototxt文件
https://www.jianshu.com/p/1a420445deea 作者:MapReducer 链接:https://www.jianshu.com/p/1a420445deea 來源:简书 ...
- python之smtplib库学习
# -*- coding:utf-8 -*- import smtplibfrom email.mime.text import MIMETextfrom email import encodersf ...
- 牛奶ddw如何通过以太坊钱包实现互相打赏
很多朋友不清楚如何转账ddw,但是万能的网友是无敌的,这两天就自己摸索的一点经验总结下今天的转账经验. 1. 提取到自己的账户 这个大家都知道如何操作,使用官方的钱包 在“日日盈app”中点击&quo ...
- Effective C++笔记(三):资源管理
参考:http://www.cnblogs.com/ronny/p/3745098.html 资源:动态分配的内存.文件描述器.互斥锁.图形界面中的字型与笔刷.数据库连接以及网络sockets等, ...
- 前端html第三方登录集合,微信,微博,QQ
申请开发者账号之内的就不累赘了,网上一大堆: 说下需求,一个网页要在三类容器运行,公司app,微信自动登录,浏览器. 假设是已经申请完成各平台开发者账号. 先来简单的,微博和QQ 微博: 引入微博JS ...
- javaScript传递参数,参数变化问题
值传递 var a=10; b(a); function b(v){ v--; } alert(a); //out 10 对象传递 var a={}; a.v=10; b(a); function b ...
- IOS-优质应用推荐
壁纸应用 cuto 免费 点击下载 shots 收费 点击下载 Cutisan 锁屏壁纸制作下载地址 待办事项 TodayMind - 提醒事项触手可及 点击下载 滴答清单 点击下载 Microsof ...
- scala学习5--函数二
to def test() : Unit = { // for(i <- 1.to(100)){ // println(i) // } for(i <- 1 to 100 ){ prin ...