ccsu 数星星

#include
#include
using namespace std;
int start[1001][1001]={0};
int main()
{
    int n,m;
    int x,y;
    int num,x1,y1,x2,y2,sum;
    scanf("%d",&n);
    for(int i=0;i0 && start[y1-1][j]

  在题目中每组数据都有m个问题,而m<=10000。所以必须先对整个坐标进行扫描将每个纵坐标上的星星数累加,

使得例如:(1,x)没有星星,则start[1][x]=0;(2,x)有星星,则start[2][x]=2;(3,x)有星星,则start[3][x]=3;

如此累计,则(y,x)点start[y][x]代表该点的下面有几颗星星,当矩形给出后,每个start[y2][x]-start[y1][x] 累加,就为该矩形中星星的数量。(但是,若(y1,x)点上有星星,则需在start[y2][x]-start[y1][x]+1,

 而(y1,x)上有星星:if(start[y1][x]>start[y1-1][x]  || y1==0 && start[y1][x]=1))

你可能感兴趣的:(枚举,关于程序)