题目链接:http://poj.org/problem?id=1656

 

#include <stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

int maps[105][105];

int main()
{
    int t;
    scanf("%d",&t);
    memset(maps,0,sizeof(maps));

    while(t--)
    {
        char order[20];
        scanf("%s",order);
        int x,y,l;
        scanf("%d%d%d",&x,&y,&l);

        if(!strcmp(order,"BLACK"))
        {
            for(int i=x;i<=x+l-1;i++)
            {
                for(int j=y;j<=y+l-1;j++)
                    maps[i][j]=1;
            }
        }

        if(!strcmp(order,"WHITE"))
        {
            for(int i=x;i<=x+l-1;i++)
            {
                for(int j=y;j<=y+l-1;j++)
                    maps[i][j]=0;
            }
        }

        if(!strcmp(order,"TEST"))
        {
            int ans=0;
            for(int i=x;i<=x+l-1;i++)
            {
                for(int j=y;j<=y+l-1;j++)
                    if(maps[i][j]==1)
                    ans++;
            }
            printf("%d\n",ans);
        }

    }
    return 0;
}

 

相关文章:

  • 2021-08-20
  • 2021-10-21
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
猜你喜欢
  • 2021-05-16
  • 2022-01-02
  • 2021-12-09
  • 2021-09-10
  • 2021-07-11
相关资源
相似解决方案