02.17 Kalevitch and Chess

Kalevitch and Chess | JXNUOJ

描述:

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.

一个著名的Berland的画家Kalevitch喜欢震惊众人。他最后痴迷之一是象棋。千年来,人们一直在枯燥的棋盘上玩这个古老的游戏。Kalevitch决定结束这一传统,开始一个对待棋盘的新态度。

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.

在以前,棋盘是一个方正的正方形,排列成8*8,每个格子被涂成黑色或者白色。Kalevitch建议棋盘应该按照一下方式上色:需要选择8个正方形的水平行或垂直线(行或列),涂成黑色。首先棋盘全是白色,可以按照以上方式涂多次。允许对一个方形涂多次,但涂一次以后颜色就不会改变且维持黑色。Kalevitch将棋盘画的整整齐齐,不可能通过笔画猜出他是怎么画的。

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.

Kalevitch希望这样的棋盘能变得流行,他将受委托绘制棋盘,这将帮助他安度晚年。客户会告知他们想要绘制怎么样的棋盘,花者将会满足他们的要求。

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.

毋庸置疑,在这样的商业中,人们应该节省一切——他想知道任何一个棋盘制作所需要的最少笔画能够满足顾客的需要。你需要帮助Kalevitch完成这项任务。

输入:

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为满足客户需求的所需的最少行和列的笔画数。

样例输入:

WWWBWWBW
BBBBBBBB
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW
WWWBWWBW

样例输出:

3

样例输入:

WWWWWWWW
BBBBBBBB
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW
WWWWWWWW

样例输出:

1
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值