460 - Overlapping Rectangles

All about problems in Volume 4. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Andrey Popyk
New poster
Posts: 6
Joined: Wed Jan 16, 2002 2:00 am
Location: Ukraine
Contact:

Post by Andrey Popyk »

Wy i received Wrong Answer?
It is very simple problem...


#include <iostream.h>

int min(int a,int b)
{ if (a<b) return a; else return b;}

int max(int a,int b)
{ if (a>b) return a; else return b;}

int main()
{
int l1,r1,u1,d1,l2,r2,u2,d2;
cin>>l1>>d1>>r1>>u1;
cin>>l2>>d2>>r2>>u2;
l1=max(l1,l2); r1=min(r1,r2);
u1=min(u1,u2); d2=max(d1,d2);
if (l1>=r1 || d1>=u1) cout<<"No Overlap"<<endl;
else cout<<l1<<' '<<d1<<' '<<r1<<' '<<u1<<endl;
return 0;
}

Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post by Adrian Kuegel »

I think you have to use d2 instead of d1, that means
if (l1>=r1 || max(d1,d2)>=u1) cout<<"No Overlap"<<endl;
else cout<<l1<<' '<<max(d1,d2)<<' '<<r1<<' '<<u1<<endl;

Andrey Popyk
New poster
Posts: 6
Joined: Wed Jan 16, 2002 2:00 am
Location: Ukraine
Contact:

Post by Andrey Popyk »

Thanks, I correct this stupid bug, but I received WA again.
I am confused, can anyone help me?

#include <iostream.h>

int min(int a,int b)
{ if (a<b) return a; else return b;}

int max(int a,int b)
{ if (a>b) return a; else return b;}

int main()
{
int l1,r1,u1,d1,l2,r2,u2,d2;
cin>>l1>>d1>>r1>>u1;
cin>>l2>>d2>>r2>>u2;
l1=max(l1,l2); r1=min(r1,r2);
u1=min(u1,u2); d1=max(d1,d2);
if (l1>=r1 || d1>=u1) cout<<"No Overlap"<<endl;
else cout<<l1<<' '<<d1<<' '<<r1<<' '<<u1<<endl;
return 0;
}

Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post by Adrian Kuegel »

You must print a blank line between the test cases (multiple input).

Andrey Popyk
New poster
Posts: 6
Joined: Wed Jan 16, 2002 2:00 am
Location: Ukraine
Contact:

Post by Andrey Popyk »

Thanks, I got Accepted.

Chung Ha, Yun
New poster
Posts: 19
Joined: Tue Jul 16, 2002 5:56 pm
Location: Seoul
Contact:

[460] Is This Multiple Input??? -_-;;;

Post by Chung Ha, Yun »

Why WA??

This problem is Multiple Input?

I don't know my mistake.... :cry:

[cpp]
#include <iostream>
using namespace std;

int min(int a,int b);
int max(int a,int b);

int main()
{
int XLL1,YLL1,XUR1,YUR1,XLL2,YLL2,XUR2,YUR2;
cin>>XLL1>>YLL1>>XUR1>>YUR1;
cin>>XLL2>>YLL2>>XUR2>>YUR2;

XLL1=max(XLL1,XLL2);
XUR1=min(XUR1,XUR2);
YUR1=min(YUR1,YUR2);
YLL1=max(YLL1,YLL2);
if((XLL1 >= XUR1) || (YLL1 >= YUR1))
cout<<"No Overlap"<<endl;
else
cout<<XLL1<<' '<<YLL1<<' '<<XUR1<<' '<<YUR1<<endl;
return 0;
}

int min(int a,int b)
{
return a < b ? a : b;
}

int max(int a,int b)
{
return a > b ? a : b;
} [/cpp]

liusu
New poster
Posts: 22
Joined: Thu Aug 01, 2002 10:26 am

minput!

Post by liusu »

yes,it's minput!so there is some prblrm with your input.you can see the page below:
http://acm.uva.es/problemset/minput.html

afonsocsc
New poster
Posts: 34
Joined: Mon Mar 24, 2003 1:15 am
Location: Portugal, Lisbon

460 WA

Post by afonsocsc »

Keeps getting wa, don't know why...
Is there some trick?

[c]
...
[/c]
Last edited by afonsocsc on Fri Apr 11, 2003 12:43 pm, edited 1 time in total.

turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:

Post by turuthok »

Looks like this problem has a "multiple-input" format ... I don't think your solution handles this.

-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).

afonsocsc
New poster
Posts: 34
Joined: Mon Mar 24, 2003 1:15 am
Location: Portugal, Lisbon

Post by afonsocsc »

Fixed it, thanks! :D
They should say it in the problem... :(

leonardooo
New poster
Posts: 8
Joined: Sun Nov 28, 2004 9:26 am
Location: Campina Grande - PB / Brazil

460 - Overlapping Rectangles

Post by leonardooo »

What's wrong with my code? I got WA many times!!! Somebody has input test cases?

[java]
//Problem 460
//Code removed because author got AC !!!
[/java]

thx
Last edited by leonardooo on Mon Nov 29, 2004 7:46 am, edited 1 time in total.
Eu sou foda? N

shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim »

consider the input:
0 0 10 10
10 5 30 30
The output should be No Overlap.

leonardooo
New poster
Posts: 8
Joined: Sun Nov 28, 2004 9:26 am
Location: Campina Grande - PB / Brazil

Post by leonardooo »

but problem text says: "Note that two windows that share a common edge but have no other points in common are considered to have ``No Overlap"."

in your test case, there are more than one common points: 10,5 10,6 10,7 10,8 10,9 10,10

my program output 10 5 10 10

:(
Eu sou foda? N

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel »

leonardooo wrote: but problem text says: "Note that two windows that share a common edge but have no other points in common are considered to have ``No Overlap"."

in your test case, there are more than one common points: 10,5 10,6 10,7 10,8 10,9 10,10

my program output 10 5 10 10
It's is true that there are more than one common points, but all the points are part of the same edge, isn't it. And there is no other point that is common and does not lie on this edge.
Therefore the answer should be 'No Overlap'.

and consider your output( 10 5 10 10 ) -- it is a line, not a rectangle.

leonardooo
New poster
Posts: 8
Joined: Sun Nov 28, 2004 9:26 am
Location: Campina Grande - PB / Brazil

Post by leonardooo »

Oh, thanks Guys, now I got AC !!!

:D :) :lol: 8) :P :wink:
Eu sou foda? N

Post Reply

Return to “Volume 4 (400-499)”