xindoo is
always here

Codeforces Round #192 (Div. 2) (330A) A. Cakeminator


题意:

       如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕。

//cf 192 div2
#include <stdio.h>
#include <string.h>

int vis[11][11];
char map[11][11];

int main()
{
    int r, c;
    while (scanf("%d %d", &r, &c) != EOF)
    {
        for (int i = 1; i <= r; i++)
            scanf("%s", &map[i][1]);
        memset(vis, 0, sizeof (vis));
        for (int i = 1; i <= r; i++)
        {
            int flag = 1;
            for (int j = 1; j <= c; j++)
            {
                if (map[i][j] == 'S')
                {
                    flag = 0;
                    break;
                }
            }
            if (flag)
            {
                for (int j = 1; j <= c; j++)
                    vis[i][j] = 1;
            }
        }
        for (int i = 1; i <= c; i++)
        {
            int flag = 1;
            for (int j = 1; j <= r; j++)
            {
                if (map[j][i] == 'S')
                {
                    flag = 0;
                    break;
                }
            }
            if (flag)
            {
                for (int j = 1; j <= r; j++)
                vis[j][i] = 1;
            }
        }
        int sum = 0;
        for (int i = 1; i <= r; i++)
        {
            for (int j = 1; j <= c; j++)
            {
                if (vis[i][j] == 1)
                    sum++;
            }
        }
        printf("%d\n", sum);
    }
    return 0;
}


打赏
未经允许不得转载:XINDOO » Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
分享到: 更多 (0)

评论 抢沙发

xindoo

联系我联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏