### 11601 - Avoiding Overlaps

Posted:

**Wed Apr 08, 2009 11:52 am**Some 1 please help me. is there any thing missing??

Why m getting wa?

Why m getting wa?

Code: Select all

```
#include<math.h>
int distance(int x1,int y1,int x2,int y2)
{
int d;
d = sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
return d;
}
int main()
{
int t,n,x1,y1,x2,y2,c=0,i,j,overlap,length,width,area;
bool num[201][201];
scanf("%d",&t);
while(t--)
{
bool enter=0;
area=0;
for(i=0;i<201;i++)for(j=0;j<201;j++)num[i][j]=0;
scanf("%d",&n);
while(n--)
{
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
x1+=99;x2+=99;y1+=99;y2+=99;
if(!enter)
{
length = distance(x1,y1,x2,y1);
width = distance(x1,y1,x1,y2);
area = length*width;
for(i=x1;i<=x2;i++)
for(j=y1;j<=y2;j++)
num[i][j]=1;
enter=1;
}
else
{
overlap=0;
for(i=x1+1;i<x2;i++){for(j=y1+1;j<y2;j++){if(num[i][j]==1){overlap = 1;break;}}}
if(!overlap)
{
length = distance(x1,y1,x2,y1);
width = distance(x1,y1,x1,y2);
area += length*width;
for(i=x1;i<x2;i++)
for(j=y1;j<y2;j++)
num[i][j]=1;
}
}
}
c++;
printf("Case %d: %d\n",c,area);
}
return 0;
}
```