11232 - Cylinder

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

Moderator: Board moderators

11232 - Cylinder

Postby David Kjaer » Sat Jul 07, 2007 5:54 pm

Is it just me or is the answer for the second test input not optimal....

My binary search gives a radius of 6.036325 - not 5 as the statement says - and that gives a volume of 1144.709. I have checked whether this cylinder is legal and it seems so...

Is it a quirk in the problem statement i got wrong?
Randers FC l
David Kjaer
New poster
 
Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

Postby mf » Sat Jul 07, 2007 6:00 pm

You can't cut out that circle. You need a sheet of paper of width at least 2r (the circle's diameter) to cut out a circle of radius r.
mf
Guru
 
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland

Postby David Kjaer » Sat Jul 07, 2007 6:06 pm

What a mindnumbingly stupid mistake...

I agree... Thanks
Randers FC l
David Kjaer
New poster
 
Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

Postby David Kjaer » Sat Jul 07, 2007 9:34 pm

I still get WA on this one....

I lean towards a precision error, but there might be a hidden bug somewhere.

Here is my code..

Code: Select all
Acc
Last edited by David Kjaer on Sat Jul 07, 2007 9:55 pm, edited 1 time in total.
Randers FC l
David Kjaer
New poster
 
Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

Postby mf » Sat Jul 07, 2007 9:48 pm

I'd suggest to replace binary search by:
Code: Select all
my = min(width/2, len/(2*PI+2)).
mf
Guru
 
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland

Postby David Kjaer » Sat Jul 07, 2007 9:56 pm

Thanks mate...

It seems to be a precision issue, caused by the binary search...
Randers FC l
David Kjaer
New poster
 
Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

Postby dplt » Sun Jul 08, 2007 10:27 am

well .. I tried to solve it by counting both the volumes if the paper is folded
horizontally and vertically. Then, choose the biggest one.
Afterall, all of sudden just give me more Wrong Answers...

Is it just me or is the answer for the second test input not optimal....

My binary search gives a radius of 6.036325 - not 5 as the statement says - and that gives a volume of 1144.709. I have checked whether this cylinder is legal and it seems so...

Is it a quirk in the problem statement i got wrong?


Actually, David, I have no idea why Binary Search used for...

my code is actually simple. Just give me a hand please.

Code: Select all
code removed
Last edited by dplt on Sun Jul 08, 2007 1:53 pm, edited 1 time in total.
dplt
New poster
 
Posts: 4
Joined: Thu Feb 15, 2007 4:30 pm
Location: Indonesia

Postby sohel » Sun Jul 08, 2007 10:35 am

Change all floats to doubles.

"Float" often causes precision error.
User avatar
sohel
Guru
 
Posts: 862
Joined: Thu Jan 30, 2003 5:50 am
Location: University of Texas at San Antonio

Postby sclo » Sun Jul 08, 2007 1:08 pm

Also, please remove the solution from the board. It's too much of a spoiler.
sclo
Guru
 
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada

Postby dplt » Sun Jul 08, 2007 1:55 pm

sohel, you're right. I never expect such kind of error processing...

better check next time..

sclo, I've done it :)
dplt
New poster
 
Posts: 4
Joined: Thu Feb 15, 2007 4:30 pm
Location: Indonesia

Postby arsalan_mousavian » Sun Jul 08, 2007 7:17 pm

i've got many WAs during the contest and after contest, can somebody tell me why my solution is wrong
here is my code:
Code: Select all
//removed
Last edited by arsalan_mousavian on Sun Jul 08, 2007 8:45 pm, edited 1 time in total.
In being unlucky I have the record.
User avatar
arsalan_mousavian
Experienced poster
 
Posts: 111
Joined: Mon Jan 09, 2006 6:19 pm
Location: Tehran, Iran

Postby Adrian Kuegel » Sun Jul 08, 2007 8:12 pm

Why do you think your binary search should work?
You could use a ternary search, but actually only if you use two different ternary searches, one for the case with horizontal roll up, the other for vertical roll up. But I suggest you think more about this problem, then you can find a solution without any ternary search.
Adrian Kuegel
Guru
 
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Postby Wei-Ming Chen » Mon Jul 09, 2007 6:25 pm

I am tired because of many WAs..

Can someone give some strickly I/O?

thanks very much..
Wei-Ming Chen
Experienced poster
 
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Postby Rocky » Mon Jul 09, 2007 11:09 pm

here some random sample...may it helpfull...

input
Code: Select all
5 5
50 50
80 80
50 80
20 50
40 80
45 50
5 6
4 5
2 3
0 0


output
Code: Select all
6.781
6780.897
27774.554
14652.276
2289.418
11721.821
5748.996
8.770
4.745
0.824


GOOD LUCK
Rocky
User avatar
Rocky
Experienced poster
 
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am

Postby Wei-Ming Chen » Tue Jul 10, 2007 8:54 am

thanks.. but my outputs are same as yours..

I tried some other inputs, can someone check my outputs for me?

input
Code: Select all
7 8
4 52
1 47
54 69
47 52
32 78
4 55
4 77
5 86
54 100
7 89
43 55
1 63
1 25
23 44
0 0


output
Code: Select all
22.506
50.265
0.785
12022.696
6511.038
8914.445
50.265
50.265
98.175
24725.716
269.392
6078.695
0.785
0.785
2038.864
Last edited by Wei-Ming Chen on Tue Jul 10, 2007 12:26 pm, edited 1 time in total.
Wei-Ming Chen
Experienced poster
 
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Next

Return to Volume CXII

Who is online

Users browsing this forum: No registered users and 1 guest