2022.02.06翻译President‘s Office

President's Office
题目(https://acs.jxnu.edu.cn/problem/CF6B)描述:
President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides are parallel to the office walls. One day President decided to establish an assembly, of which all his deputies will be members. Unfortunately, he does not remember the exact amount of his deputies, but he remembers that the desk of each his deputy is adjacent to his own desk, that is to say, the two desks (President's and each deputy's) have a common side of a positive length.

The office-room plan can be viewed as a matrix with n rows and m columns. Each cell of this matrix is either empty, or contains a part of a desk. An uppercase Latin letter stands for each desk colour. The «period» character («.») stands for an empty cell.

输入:
The first line contains two separated by a space integer numbers n, m (1 ≤ n, m ≤ 100) — the length and the width of the office-room, and c character — the President's desk colour. The following n lines contain m characters each — the office-room description. It is guaranteed that the colour of each desk is unique, and each desk represents a continuous subrectangle of the given matrix. All colours are marked by uppercase Latin letters.

输出:
Print the only number — the amount of President's deputies.

样例输入:
3 4 R
G.B.
.RR.
TTT.
样例输出:
2
样例输入:
3 3 Z
...
.H.
..Z
样例输出:
0

翻译:
波兰的总统有一个非常大的行政宫殿,除了他,还有随员在这里工作。每个随员,包括总统,都有一张颜色独一无二的桌子。每张桌子都是矩形的,并且桌子边缘与墙壁平行。一天,总统想建立一个议会,他的代表为议会成员。不幸的是,他不记得他的代表的具体数量,但是他记得他的每个代表的桌子和他自己的桌子相邻,也就是说两张桌子(总统的和每个随员的)有一条相同的边。

行政宫殿可以看成一个n行m列的矩阵。矩阵的每个格子都是空的,或者包含桌子的一部分。一个大写字母表示桌子的颜色。«period»  («.»)表示一个空的格子。
输入:
第一行包含两个用单空格分开的整数n,m(1 ≤ n, m ≤ 100),表示行政宫殿的长和宽,和字符c,表示总统桌子的颜色。接下来n行包含m个字符,表示行政宫殿的描述。可以保证每个桌子颜色不一样,并且每张桌子代表给定的矩阵的一个连续子矩形。所有的字母都是大写的。
输出:
输出一个数字,表示随员的数量。
样例输入:
3 4 R
G.B.
.RR.
TTT.
样例输出:
2
样例输入:
3 3 Z
...
.H.
..Z
样例输出:
0

你可能感兴趣的:(翻译,c++)