Codeforces Round #192 (Div. 2)-A. Cakeminator
来源:互联网 发布:宁波海关数据 编辑:程序博客网 时间:2024/05/22 04:45
You are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For example, a 3 × 4 cake may look as follows:
The cakeminator is going to eat the cake! Each time he eats, he chooses a row or a column that does not contain any evil strawberries and contains at least one cake cell that has not been eaten before, and eats all the cake cells there. He may decide to eat any number of times.
Please output the maximum number of cake cells that the cakeminator can eat.
The first line contains two integers r and c (2 ≤ r, c ≤ 10), denoting the number of rows and the number of columns of the cake. The next r lines each contains c characters — the j-th character of the i-th line denotes the content of the cell at row i and column j, and is either one of these:
- '.' character denotes a cake cell with no evil strawberry;
- 'S' character denotes a cake cell with an evil strawberry.
Output the maximum number of cake cells that the cakeminator can eat.
3 4S.........S.
8
水题:
AC代码:
#include<iostream>#include<cstring>#include<cstdio>const int MAX=11;char map[MAX][MAX];int shuzu[MAX][MAX];int r,c;using namespace std;int main(){int i,j,sum,sum_r,sum_c,k;cin>>r>>c;for(i=0;i<r;i++){getchar();for(j=0;j<c;j++){cin>>map[i][j];if(map[i][j]=='S')shuzu[i][j]=0;elseshuzu[i][j]=1;}}sum_r=0;sum_c=0;sum=0;for(i=0;i<r;i++){sum_r=0;for(j=0;j<c;j++){if(map[i][j]=='.'){if(shuzu[i][j]==1){sum_r+=1;shuzu[i][j]=0;}}else{sum_r=0;break;}}if(sum_r==0){for(j=0;j<c;j++){if(map[i][j]=='.')shuzu[i][j]=1;elseshuzu[i][j]=0;}}sum+=sum_r;}for(i=0;i<c;i++){sum_c=0;for(j=0;j<r;j++){if(map[j][i]=='.'){if(shuzu[j][i]==1)sum_c+=1;}else{sum_c=0;break;}}sum+=sum_c;}cout<<sum<<endl;return 0;}
For the first example, one possible way to eat the maximum number of cake cells is as follows (perform 3 eats).
- Codeforces Round #192 (Div. 2)-A. Cakeminator
- Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
- codeforces A. Cakeminator 题解
- codeforces 330A Cakeminator
- codeforces 330A Cakeminator
- Codeforces Round #192 (Div. 2) A题
- Codeforces 330A Cakeminator(模拟)
- Codeforces Round #192 (Div. 2) (329A)C.Purification
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- Codeforces Round #181 (Div. 2) A题
- Codeforces Round #184 (Div. 2) A题
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #172 (Div. 2) A题
- Codeforces Round #166 (Div. 2) A题
- Codeforces Round #132 (Div. 2) A题
- Codeforces Round #131 (Div. 2) A题
- android编程
- 20130721-lua binder另一只轮子的雏形
- MFC对话框之间自定义消息传递
- 有12个球,其中有一个是假球,且与其它球的重量不同。用一个无法码天平称三次找出这个球,并确定比其它球重,或是轻。
- POJ1564(DFS构造法) Sum It Up
- Codeforces Round #192 (Div. 2)-A. Cakeminator
- 线程池中利用函数指针对任务的动态绑定
- Codeforces Round #192 (Div. 2)-B. Road Construction
- 回滚段测试
- python 赋值
- MapReduce编程基础
- struts1配置动态actionForm
- Search a 2D Matrix
- 无穷数的定义