10577 - Bounding box

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

Moderator: Board moderators

Post Reply
Almorrana
New poster
Posts: 3
Joined: Thu Nov 06, 2003 9:07 pm

10577 - Bounding box

Post by Almorrana » Thu Nov 06, 2003 9:14 pm

My algorithm is as follows:

1. If numVertex=3
Calc the bounding box just getting the max/min x/y coords

2. If numVertex > 3
Calc the circumcenter of the three vertex, and then, with one given vertex and the circumcenter, generate all the numVertex vertices (circunference equation). With all these points, calc the max/min on x/y coords to get the bounding box.

Something wrong? With all the test cases it works fine.
Thx

Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post by Larry » Fri Nov 07, 2003 12:36 am

Sounds right. Perhaps you have a precision problem?

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

Post by Adrian Kuegel » Fri Nov 07, 2003 2:18 pm

I used the same algorithm, and I had a precision problem, too. Because I didn't know what was wrong I checked my program with the Waterloo Test Cases. Only for one input I got a different output, so I made a special case for it.

ginie
New poster
Posts: 4
Joined: Sun Feb 20, 2005 11:46 pm

10577 Feed up of bounding boxes

Post by ginie » Sun Feb 20, 2005 11:57 pm

Hi people!!
Does anybody know what's the problem with my code for 10577?
I calculate the incenter of the traingle made with the 4 vertex and then calcule the other ones knowing that the polygon is regular and with n sides.
#include <iostream.h>
#include <stdio.h>
#include <math.h>

const float pi=3.14159265358979323846f;

double max(double x, double y)
{
double maxi;
if (x>y) maxi=x;
else maxi=y;
return(maxi);
}
double min(double x, double y)
{
double mini;
if (x<y) mini=x;
else mini=y;
return(mini);
}
void main()
{
int n,num,i;
double x[150],y[150],area,r0,r1,r2,xc,yc,x0,x1,x2,y0,y1,y2,cs,sn,maximx,minimx,maximy,minimy;

num=num^num;
cin >> n;
while(n!=0)
{
num++;
cin >> x[0]>> y[0];
cin >> x[1]>> y[1];
cin >> x[2]>> y[2];

if(n==3)
{
maximx=x[0];minimx=x[0];maximy=y[0];minimy=y[0];
for(i=1; i<3; i++)
{
maximx=max(maximx,x);
maximy=max(maximy,y);
minimx=min(minimx,x);
minimy=min(minimy,y);
}

area=(maximx-minimx)*(maximy-minimy);
}
else
{
r0=x[0]*x[0]+y[0]*y[0];
r1=x[1]*x[1]+y[1]*y[1];
r2=x[2]*x[2]+y[2]*y[2];
x0=y[1]-y[2];y0=x[1]-x[2];
x1=y[2]-y[0];y1=x[2]-x[0];
x2=y[0]-y[1];y2=x[0]-x[1];
xc=(r0*x0+r1*x1+r2*x2)/(2*(x[0]*x0+x[1]*x1+x[2]*x2));
yc=(r0*y0+r1*y1+r2*y2)/(2*(y[0]*y0+y[1]*y1+y[2]*y2));
for(i=1; i<n; i++)
{
cs=cos(2*pi*i/n);sn=sin(2*pi*i/n);
x=x[0]*cs-y[0]*sn+xc;
y=x[0]*sn+cs*y[0]+yc;
}

maximx=x[0];minimx=x[0];maximy=y[0];minimy=y[0];
for(i=1; i<n; i++)
{
maximx=max(maximx,x);
maximy=max(maximy,y);
minimx=min(minimx,x);
minimy=min(minimy,x);
}

area=(maximx-minimx)*(maximy-minimy);

}

cout <<"Polygon "<< num <<": "<< area<<endl;
cin >> n;
}
}

minskcity
Experienced poster
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Post by minskcity » Tue May 03, 2005 9:40 pm

Where can I find those "Waterloo Test Cases"?

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Wed May 04, 2005 7:51 am


minskcity
Experienced poster
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Post by minskcity » Wed May 04, 2005 4:13 pm

Thanks. I looked over the page, but could not find the "bounding box" problem :( . Do you have any idea where it can be? I looked at contests dated 2001+, because on UVA it says "Local_UVa'2003"...

daveon
Experienced poster
Posts: 229
Joined: Tue Aug 31, 2004 2:41 am
Location: TORONTO, CANADA

Post by daveon » Tue Aug 23, 2005 2:24 am

Hi,

Look for 22 September 2001 - Waterloo local contest
PROBLEM D.

minskcity
Experienced poster
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Post by minskcity » Sun Sep 04, 2005 11:57 pm

Thanks, got AC now :D

HHH
New poster
Posts: 2
Joined: Wed Aug 22, 2012 9:20 pm

Re: 10577 - Bounding Box

Post by HHH » Wed Aug 22, 2012 9:33 pm

can you plz post these cases as the page don't want to open with me :D

HHH
New poster
Posts: 2
Joined: Wed Aug 22, 2012 9:20 pm

Re:

Post by HHH » Wed Aug 22, 2012 10:24 pm

daveon wrote:Hi,

Look for 22 September 2001 - Waterloo local contest
PROBLEM D.
plz I need these cases :(

blegat
New poster
Posts: 3
Joined: Fri Apr 04, 2014 12:58 pm

Re: 10577 - Bounding Box

Post by blegat » Fri Apr 04, 2014 1:38 pm

Important details, output the numbers with exactly 3 decimals or you will get WA.
Here are the inpust/outputs
Attachments
input-output-10577.zip
(1.65 KiB) Downloaded 106 times

Post Reply

Return to “Volume 105 (10500-10599)”