Page 1 of 3

11232 - Cylinder

Posted: Sat Jul 07, 2007 5:54 pm
by David Kjaer
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?

Posted: Sat Jul 07, 2007 6:00 pm
by mf
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.

Posted: Sat Jul 07, 2007 6:06 pm
by David Kjaer
What a mindnumbingly stupid mistake...

I agree... Thanks

Posted: Sat Jul 07, 2007 9:34 pm
by David Kjaer
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

Posted: Sat Jul 07, 2007 9:48 pm
by mf
I'd suggest to replace binary search by:

Code: Select all

my = min(width/2, len/(2*PI+2)).

Posted: Sat Jul 07, 2007 9:56 pm
by David Kjaer
Thanks mate...

It seems to be a precision issue, caused by the binary search...

Posted: Sun Jul 08, 2007 10:27 am
by dplt
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

Posted: Sun Jul 08, 2007 10:35 am
by sohel
Change all floats to doubles.

"Float" often causes precision error.

Posted: Sun Jul 08, 2007 1:08 pm
by sclo
Also, please remove the solution from the board. It's too much of a spoiler.

Posted: Sun Jul 08, 2007 1:55 pm
by dplt
sohel, you're right. I never expect such kind of error processing...

better check next time..

sclo, I've done it :)

Posted: Sun Jul 08, 2007 7:17 pm
by arsalan_mousavian
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

Posted: Sun Jul 08, 2007 8:12 pm
by Adrian Kuegel
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.

Posted: Mon Jul 09, 2007 6:25 pm
by Wei-Ming Chen
I am tired because of many WAs..

Can someone give some strickly I/O?

thanks very much..

Posted: Mon Jul 09, 2007 11:09 pm
by Rocky
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

Posted: Tue Jul 10, 2007 8:54 am
by Wei-Ming Chen
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