A. Cakeminator
来源:互联网 发布:usb摄像头软件 编辑:程序博客网 时间:2024/05/21 18:42
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 iand 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
For the first example, one possible way to eat the maximum number of cake cells is as follows (perform 3 eats).
解题说明:题目的意思翻译过来是求解该行或该列不含草莓标记的所有蛋糕数之和,可以先标记出草莓所在的行和列,然后针对某个蛋糕就可以判断该行或该列是否有草莓,如果没有就相加。
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include<set>#include <algorithm>using namespace std;int main(){int n,m,i,j;int r[11],c[11];int ans=0;char ch;memset(r,0,sizeof(r));memset(c,0,sizeof(c));scanf("%d %d",&n,&m);for(i=0;i<n;++i){for(j=0;j<m;++j){cin>>ch;if(ch=='S'){r[i]=c[j]=1;}}}ans=n*m;for(i=0;i<n;++i){for( j=0;j<m;++j) {if(r[i] && c[j]) {ans--;}}}printf("%d\n",ans);return 0;}
- A. Cakeminator
- A. Cakeminator
- cf192 div2 A. Cakeminator
- codeforces A. Cakeminator 题解
- codeforces 330A Cakeminator
- codeforces 330A Cakeminator
- CF330 A. Cakeminator 大水题
- Codeforces 330A Cakeminator(模拟)
- Cakeminator
- Codeforces Round #192 (Div. 2)-A. Cakeminator
- Problem-330A-Codeforce Cakeminator(思维)
- Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
- a
- a
- a
- a
- a
- a
- Fedora NVIDIA显卡驱动下载地址
- ping命令的分析
- jqueery 的 ajax 用法说明
- CentOS6.4+uwsgi+nginx+django
- 题1006、1007、1008
- A. Cakeminator
- svn 提交代码 自动过滤技巧
- java设计模式---备忘录模式
- SSH框架学习笔记(一)
- hdu 1205
- WinForm与Javascript交互
- Oracle 锁机制
- 信号
- 转载]H.264RTP封包原理