11345 - Rectangles
Moderator: Board moderators
Error in statement or data?
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?
Or have I misunderstood something?
Re: Error in statement or data?
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
I'm getting WA in this problem.Can anyone tell where i did wrong ?
Or give me some io please.
Thank's in advance.
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;
}
Re: 11345 - Rectangles
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.
-
- Learning poster
- Posts: 97
- Joined: Fri Aug 22, 2008 10:18 pm
- Location: CSE.SUST.SYLHET
Re: 11345 - Rectangles
HELP PLEASE
i chuck all input and post in board but it gives me WA
can any one help me????????????????????????????????????????????????????????????
CUT AFTER AC............................
Last edited by saiful_sust on Tue Dec 30, 2008 5:54 pm, edited 1 time in total.
-
- New poster
- Posts: 32
- Joined: Sat Dec 29, 2007 9:08 pm
- Location: CSEDU , Dhaka
- Contact:
Re: 11345 - Rectangles
A learner......
-
- Learning poster
- Posts: 97
- Joined: Fri Aug 22, 2008 10:18 pm
- Location: CSE.SUST.SYLHET
Re: 11345 - Rectangles
hi shiplu.
Thanks for help.
BUT sitll i got WA
Here is my new code
CUT AFTER AC................
Last edited by saiful_sust on Tue Dec 30, 2008 5:55 pm, edited 1 time in total.
-
- New poster
- Posts: 32
- Joined: Sat Dec 29, 2007 9:08 pm
- Location: CSEDU , Dhaka
- Contact:
Re: 11345 - Rectangles
another case for you
output
Think simple. you don't need a huge check....
and please use code tag instead of quote
Code: Select all
1
2
1 1 5 5
2 6 6 10
Code: Select all
Case 1: 0
and please use code tag instead of quote
A learner......
-
- Learning poster
- Posts: 97
- Joined: Fri Aug 22, 2008 10:18 pm
- Location: CSE.SUST.SYLHET
Re: 11345 - Rectangles
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.................
Last edited by saiful_sust on Tue Dec 30, 2008 5:56 pm, edited 1 time in total.
-
- New poster
- Posts: 32
- Joined: Sat Dec 29, 2007 9:08 pm
- Location: CSEDU , Dhaka
- Contact:
Re: 11345 - Rectangles
you doesn't need this part, remove it
and change it
to
Hope that help....... 
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;
Code: Select all
if(x2<=x1 || y2<=y1)
{
set=1;
}
Code: Select all
if(X2<=X1 || Y2<=Y1)
{
set=1;
}

A learner......
-
- Learning poster
- Posts: 97
- Joined: Fri Aug 22, 2008 10:18 pm
- Location: CSE.SUST.SYLHET
Re: 11345 - Rectangles
Thanks siplu_1320
now it is AC
ur r so helpful....
![]()
-
- New poster
- Posts: 9
- Joined: Sat Jun 12, 2010 2:11 pm
- Location: Ulaanbaatar, Mongolia
- Contact:
Re: 11345 - Rectangles
Hi everyone.
I got Wa and it's frustrating me(
)
What's wrong in this code:
Thanks in Advance.
I got Wa and it's frustrating me(

What's wrong in this code:
Code: Select all
Acc
-
- New poster
- Posts: 5
- Joined: Wed Aug 11, 2010 8:52 am
Re: 11345 - Rectangles
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;
}
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;
}