A. cakeminator

Source: Internet
Author: User
Time limit per test

1 second

Memory limit per test

256 megabytes

Input

Standard Input

Output

Standard output

You are given a rectangular cake, represented asRLimit × limitCGrid. Each cell either has an edevil strawberry, or is empty. For example,
A 3 rows x rows 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 edevil 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.

Input

The first line contains two integersRAndC(2 cores ≤ CoresR, Bytes,CLimit ≤ limit 10 ),
Denoting the number of rows and the number of columns of the cake. The nextRLines each containsCCharacters
-J-Th character ofI-Th
Line denotes the content of the cell at rowIAnd ColumnJ,
And is either one of these:

  • '.' Character denotes a cake cell with no edevil strawberry;
  • 'S 'character denotes a cake cell with an edevil strawberry.

Output

Output the maximum number of cake cells that the cakeminator can eat.

Sample test (s) Input
3 4S.........S.
Output
8
Note

For the first example, one possible way to eat the maximum number of cake cells is as follows (perform 3 eats ).

Explanation: The question means to solve the sum of the number of all the cakes without the strawberry label in this row or column. You can mark the row and column of the strawberry first, then, you can determine whether there are any strawberries in this row or column for a cake. If not, add them.

#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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.