题目链接:Codeforces 330A Cakeminator
模拟,简单题。
#include <iostream>
#include <cstring>
using namespace std;
const int MAX_N = 10 + 2;
char _map[MAX_N][MAX_N];
bool row[MAX_N],column[MAX_N];
int r,c;
int solve()
{
int sum,vis;
sum = vis = 0;
for(int i = 0;i < r;i++)
{
for(int j = 0;j < c;j++)
{
if(row[i])
break;
if(j == c - 1)
{
sum += c;
vis++;
}
}
}
for(int j = 0;j < c;j++)
{
for(int i = 0;i < r;i++)
{
if(column[j])
break;
if(i == r - 1)
sum += (r - vis);
}
}
return sum;
}
int main()
{
while(cin >> r >> c)
{
memset(row,0,sizeof(row));
memset(column,0,sizeof(column));
for(int i = 0;i < r;i++)
{
for(int j = 0;j < c;j++)
{
cin >> _map[i][j];
if(_map[i][j] == 'S')
row[i] = column[j] = 1;
}
}
cout << solve() << endl;
}
return 0;
}