460 - Overlapping Rectangles
Moderator: Board moderators
-
- New poster
- Posts: 6
- Joined: Wed Jan 16, 2002 2:00 am
- Location: Ukraine
- Contact:
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;
}
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;
}
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
-
- New poster
- Posts: 6
- Joined: Wed Jan 16, 2002 2:00 am
- Location: Ukraine
- Contact:
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;
}
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;
}
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
-
- New poster
- Posts: 6
- Joined: Wed Jan 16, 2002 2:00 am
- Location: Ukraine
- Contact:
-
- New poster
- Posts: 19
- Joined: Tue Jul 16, 2002 5:56 pm
- Location: Seoul
- Contact:
[460] Is This Multiple Input??? -_-;;;
Why WA??
This problem is Multiple Input?
I don't know my mistake....
[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]
This problem is Multiple Input?
I don't know my mistake....

[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]
minput!
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
http://acm.uva.es/problemset/minput.html
-
- New poster
- Posts: 8
- Joined: Sun Nov 28, 2004 9:26 am
- Location: Campina Grande - PB / Brazil
460 - Overlapping Rectangles
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
[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
-
- New poster
- Posts: 8
- Joined: Sun Nov 28, 2004 9:26 am
- Location: Campina Grande - PB / Brazil
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.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
Therefore the answer should be 'No Overlap'.
and consider your output( 10 5 10 10 ) -- it is a line, not a rectangle.
-
- New poster
- Posts: 8
- Joined: Sun Nov 28, 2004 9:26 am
- Location: Campina Grande - PB / Brazil