Page 2 of 2

Error in statement or data?

Posted: Mon Feb 25, 2008 2:38 am
by Anders
I think there is an error in this problem. The problem statement claims that the input will describe the lower left and upper right corners of the rectangle. A situation where the lower right and upper left corners are described should therefore never occur (and a program that encounters such input should be allowed to return undefined output - at least if there were a way to verify the faulty input, which I will argue there is not). Possibly, however, the corners might be swapped, as the statement does not say anything about the order of the input. Furthermore, there is nothing that says that (1,1) is to the lower left of (2,2). It all depends on how the coordinate system is defined. Considering the statement, the only correct thing to do would thus be to sort the input. Nevertheless, if you sort the input you will get WA.

Or have I misunderstood something?

Re: Error in statement or data?

Posted: Sun Apr 27, 2008 8:08 pm
by yiuyuho
Anders wrote:I think there is an error in this problem. .... Nevertheless, if you sort the input you will get WA.

Or have I misunderstood something?

I believe you are right. This seems to be an error of input, which we have to deal with. But that's fine because this post has clarified things.

WA 11345 - Rectangles

Posted: Mon May 19, 2008 4:38 pm
by mukit
I'm getting WA in this problem.Can anyone tell where i did wrong ?
Or give me some io please.

Code: Select all

#include<iostream>
using namespace std;
#define size 35
long x1[size],y1[size],x2[size],y2[size];
long lx=10002,hx=-10002,ly=10002,hy=-10002;
long vx,vy;
int main()
{
	int n,m;
	cin>>n;
	int flag;
	for(int i=1;i<=n;i++)
	{
		cin>>m;
		flag=0;
		for(int j=0;j<m;j++)
		{
			cin>>x1[j]>>y1[j]>>x2[j]>>y2[j];
			if(x1[j]>=x2[j] || y1[j]>=y2[j])
			{
				flag=1;
				break;
			}
			if(x1[j]>hx)
			{
				hx=x1[j];
			}
			if(x2[j]<lx)
			{
				lx=x2[j];
			}
			if(y1[j]>hy)
			{
				hy=y1[j];
			}
			if(y2[j]<ly)
			{
				ly=y2[j];
			}
		}
		if(flag)
		{
			cout<<"Case "<<i<<": 0"<<endl;
		}
		else
		{
			vx=lx-hx;
			vy=ly-hy;
			cout<<"Case "<<i<<": "<<vx*vy<<endl;
		}
		lx=10002;hx=-10002;ly=10002;hy=-10002;
	}
	return 0;
}

Thank's in advance.

Re: 11345 - Rectangles

Posted: Mon May 19, 2008 4:46 pm
by yiuyuho
See your breaking statement there? You'll end up not reading part of the input for the current test case and mess up the next test case. Anyway, if x1[j]>=x2[j] or y1[j]>=y2[j], then you just skip the current rectangle, but not all of them. At least I believe that's how it's done.

Re: 11345 - Rectangles

Posted: Sun Dec 28, 2008 11:35 am
by saiful_sust
HELP PLEASE
i chuck all input and post in board but it gives me WA
can any one help me????????????????????????????????????????????????????????????

CUT AFTER AC............................

Re: 11345 - Rectangles

Posted: Sun Dec 28, 2008 3:58 pm
by shiplu_1320
try this input

Code: Select all

1
2
1 1 3 3
4 4 6 6
output:

Code: Select all

Case 1: 0
Good luck :)

Re: 11345 - Rectangles

Posted: Mon Dec 29, 2008 10:29 am
by saiful_sust
hi shiplu.
Thanks for help.
BUT sitll i got WA
Here is my new code
CUT AFTER AC................

Re: 11345 - Rectangles

Posted: Mon Dec 29, 2008 8:50 pm
by shiplu_1320
another case for you

Code: Select all

1
2
1 1 5 5
2 6 6 10
output

Code: Select all

Case 1: 0
Think simple. you don't need a huge check....
and please use code tag instead of quote

Re: 11345 - Rectangles

Posted: Tue Dec 30, 2008 11:25 am
by saiful_sust
saiful: :( :( :(
hi siplu_1320
thanks 4 ur test case
but i m sorry because still now i get WA.
i don't know why..
here is my update code

Code: Select all

CUT AFTER AC.................

Re: 11345 - Rectangles

Posted: Tue Dec 30, 2008 2:36 pm
by shiplu_1320
you doesn't need this part, remove it

Code: Select all

 if( ((x1>=X1 && x1<=X2) && (y1>=Y1 && y1<=Y2)) || ((x2>=X1 && x2<=X2)
          && (y2>=Y1 && y2<=Y2)) || ((x1>=X1 && x1<=X2) && (y2>=Y1 && y2<=Y2))
          ||   ((x2>=X1 && x2<=X2) && (y1>=Y1 && y1<=Y2)) || ((X1>=x1 && X1<=x2)
          && (Y2>=y1 && Y2<=y2)) )
         {
            set=0;            
         }
         else
            set=1;
and change it

Code: Select all

if(x2<=x1 || y2<=y1)
 {
        set=1;
  }
to

Code: Select all

if(X2<=X1 || Y2<=Y1)
{
       set=1;
 }
Hope that help....... :)

Re: 11345 - Rectangles

Posted: Tue Dec 30, 2008 5:58 pm
by saiful_sust
Thanks siplu_1320
now it is AC
ur r so helpful....

:D

Re: 11345 - Rectangles

Posted: Fri Aug 20, 2010 4:29 am
by Nursoltan_h
Hi everyone.

I got Wa and it's frustrating me( :cry: )

What's wrong in this code:

Code: Select all

Acc
Thanks in Advance.

Re: 11345 - Rectangles

Posted: Mon Aug 23, 2010 9:58 am
by asraful.ruet
prb :11345

i am getting wa .
here is my code ...
please help .


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define MAX(a, b) (a>=b?a:b)
#define MIN(a, b) (a>=b?b:a)

int main(){
int x1,x2,x3,x4,x5,x6,x7,x8,y1,y2,y3,y4,y5,y6,y7,y8,i,j,t,n,f,x;
long area;
scanf("%d",&t);
for(j=1;j<=t;j++){
scanf("%d",&n);
f=0;
scanf("%d %d %d %d",&x1,&y1,&x3,&y3);
x2=x3; y2=y1; x4=x1; y4=y3;
for(i=2;i<=n;i++){
scanf("%d %d %d %d",&x5,&y5,&x7,&y7);
x6=x7; y6=y5; x8=x5; y8=y7;
if(f==0){
if(x5>=x2 || x6<=x1 || y5>=y4 || y8<=y1){f=1;}
x1=MAX(x1,x5); y1=MAX(y1,y5);
x3=MIN(x3,x7); y3=MIN(y3,y7);
x2=x3; y2=y1; x4=x1; y4=y3;
}
}
if(f==0)
area=(long)(sqrt(pow((x1-x2),2)+pow((y1-y2),2))*sqrt(pow((x1-x4),2)+pow((y1-y4),2)));
else
area=0;
printf("Case %d: %ld\n",j,area);
}
return 0;
}