Code: Select all
5 5 2
1 1 3 2
3 0 3 5
Code: Select all
12345
1 ..F..
2 .FFF.
3 .FFF.
4 ..F..
5 ..F..
Moderator: Board moderators
Code: Select all
5 5 2
1 1 3 2
3 0 3 5
Code: Select all
12345
1 ..F..
2 .FFF.
3 .FFF.
4 ..F..
5 ..F..
Code: Select all
int W,H,N,i,j,x1,x2,y1,y2,k,max_x,min_x,max_y,min_y;
long long count;
while(scanf("%d %d %d",&W,&H,&N)==3)
{
if(!W&&!H&&!N)
break;
for(i = 0; i < W; i++)
for(j = 0; j < H; j++)
board[i][j] = '0';
for(k = 0; k < N; k++ )
{
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
if(x1>x2)
{
max_x = x1;
min_x = x2;
}
else
{
max_x = x2;
min_x = x1;
}
if(y1>y2)
{
max_y = y1;
min_y = y2;
}
else
{
max_y = y2;
min_y = y1;
}
for(i = min_x; i < max_x; i++)
{
for(j = min_y; j < max_y; j++)
{
board[i][j] = '1';
}
}
}
count = 0;
for(i = 0; i < W; i++)
for(j = 0; j < H; j++)
if(board[i][j]=='0')
count++;
if(!count)
printf("There is no empty spots.\n");
else if(count==1)
printf("There is one empty spot.\n");
else
printf("There is %lld empty spots.\n",count);
}
Code: Select all
for(i = min_x-1; i < max_x; i++)
{
for(j = min_y-1; j < max_y; j++)
{
board[i][j] = '1';
}
}
Code: Select all
#include<stdio.h>
#define sz 502
int main()
{
long arr[sz][sz],w,h,sub,s,i,j,x1,y1,x2,y2,flag=0,temp,count;
while(scanf("%ld %ld %ld",&w,&h,&sub)==3 && (w!=0 ||h!=0 || sub!=0 ))
{
for(i=1;i<=w;i++)
for(j=1;j<=h;j++)
arr[i][j]=1;
count = 0;
for(s=0;s<sub;s++)
{
scanf("%ld %ld %ld %ld",&x1,&y1,&x2,&y2);
if(x1>x2)
{
temp =x2;
x2=x1;
x1=temp;
}
if(y1>y2)
{
temp =y2;
y2=y1;
y1=temp;
}
for(i=x1;i<=x2;i++)
for(j=y1;j<=y2;j++)
arr[i][j]=0;
}
for(i=1;i<=w;i++)
for(j=1;j<=h;j++)
if(arr[i][j]==1)
count++;
if(count==0)
printf("There is no empty spots.\n");
else if(count==1)
printf("There is one empty spots.\n");
else
printf("There are %ld empty spots.\n",count);
}
return 0;
}
I found your bug. The problem is in the following linehi,
i am getting WA in that problem.
my program generates good ans for all the inputs in the board.
will any one help me.
here is my code:
Code: Select all
cut..
Code: Select all
500 500 0
0 0 0
Code: Select all
There are 250000 empty spots.