Problem Statement
There are �N rectangular sheets spread out on a coordinate plane.
Each side of the rectangular region covered by each sheet is parallel to the �x- or �y-axis.
Specifically, the �i-th sheet covers exactly the region satisfying ��≤�≤��Ai≤x≤Bi and ��≤�≤��Ci≤y≤Di.
Let �S be the area of the region covered by one or more sheets. It can be proved that �S is an integer under the constraints.
Print �S as an integer.
Constraints
- 2≤�≤1002≤N≤100
- 0≤��<��≤1000≤Ai<Bi≤100
- 0≤��<��≤1000≤Ci<Di≤100
- All input values are integers.
笔者答案:
#include<stdio.h>
int main()
{
int N,A,B,C,D;
int i,j,m,n;
int cnt=0;
int a[101][101];
scanf("%d",&N);
for(i=0;i<=99;i++)
{
for(j=0;j<=99;j++)
{
a[i][j]=0;
}
}
for(i=1;i<=N;i++)
{
scanf("%d %d %d %d",&A,&B,&C,&D);
for(m=C;m<D;m++)
{
for(n=A;n<B;n++)
{
a[m][n]=1;
}
}
}
for(i=0;i<=99;i++)
{
for(j=0;j<=99;j++)
{
if(a[i][j]==1)
{
cnt++;
}
}
}
printf("%d",cnt);
return 0;
}