CF690D1.The Wall (easy)
普及-
通过率:0%
时间限制:0.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
"The zombies are lurking outside. Waiting. Moaning. And when they come..."
"When they come?"
"I hope the Wall is high enough."
Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. In places, gaps have appeared, splitting the wall into multiple segments. We call on you for help. Go forth and explore the wall! Report how many disconnected segments there are.
The wall is a two-dimensional structure made of bricks. Each brick is one unit wide and one unit high. Bricks are stacked on top of each other to form columns that are up to R bricks high. Each brick is placed either on the ground or directly on top of another brick. Consecutive non-empty columns form a wall segment. The entire wall, all the segments and empty columns in-between, is C columns wide.
僵尸正在外面潜伏着。等待着。呻吟着。而当它们来临时……
“当它们来临时?”
“但愿这堵墙足够高。”
僵尸袭击已经波及到长城——我们北方的防线。它的防护功能正在失效,裂缝已经开始显现。在某些地方,出现了缺口,将整堵墙分割成了多个独立的段落。我们向你求助:请前去探查这堵墙!并报告其中存在多少个互不连通的墙段。
这堵墙是一个二维结构,由砖块堆砌而成。每块砖宽为 1 单位、高为 1 单位。砖块垂直堆叠形成若干列,每列最高可达 $ R $ 块砖。每块砖要么直接置于地面上,要么恰好叠放在另一块砖的正上方。连续的非空列构成一个墙段。整堵墙(包括所有墙段以及其间的所有空列)共宽 $ C $ 列。
输入格式
The first line of the input consists of two space-separated integers R and C, 1 ≤ R, C ≤ 100. The next R lines provide a description of the columns as follows:
- each of the R lines contains a string of length C,
- the c-th character of line r is B if there is a brick in column c and row R - r + 1, and . otherwise.
The input will contain at least one character B and it will be valid.
输入的第一行包含两个以空格分隔的整数 R 和 C,满足 1≤R,C≤100。接下来的 R 行按如下方式描述砖块布局:
- 每行均为长度为 C 的字符串;
- 第 r 行的第 c 个字符为
B,表示在第 c 列、第 R−r+1 行处存在一块砖;否则为.。
输入中至少包含一个字符 B,且输入数据保证合法。
输出格式
The number of wall segments in the input configuration.
输入配置中墙段的数量。
输入输出样例
输入#1
3 7 ....... ....... .BB.B..
输出#1
2
输入#2
4 5 ..B.. ..B.. B.B.B BBB.B
输出#2
2
输入#3
4 6 ..B... B.B.BB BBB.BB BBBBBB
输出#3
1
输入#4
1 1 B
输出#4
1
输入#5
10 7 ....... ....... ....... ....... ....... ....... ....... ....... ...B... B.BB.B.
输出#5
3
输入#6
8 8 ........ ........ ........ ........ .B...... .B.....B .B.....B .BB...BB
输出#6
2
说明/提示
In the first sample case, the 2nd and 3rd columns define the first wall segment, and the 5th column defines the second.
在第一个样例中,第 2 列和第 3 列定义了第一段墙体,第 5 列定义了第二段墙体。
输入解题思路,AI测评打分。不知道怎么写?