11232 - Cylinder

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

Moderator: Board moderators

David Kjaer
New poster
Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

11232 - Cylinder

Post 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?
Randers FC l
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post 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.
David Kjaer
New poster
Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

Post by David Kjaer »

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

Post 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
Last edited by David Kjaer on Sat Jul 07, 2007 9:55 pm, edited 1 time in total.
Randers FC l
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

I'd suggest to replace binary search by:

Code: Select all

my = min(width/2, len/(2*PI+2)).
David Kjaer
New poster
Posts: 9
Joined: Sat Jul 07, 2007 5:47 pm
Location: Denmark

Post by David Kjaer »

Thanks mate...

It seems to be a precision issue, caused by the binary search...
Randers FC l
dplt
New poster
Posts: 4
Joined: Thu Feb 15, 2007 4:30 pm
Location: Indonesia
Contact:

Post 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
Last edited by dplt on Sun Jul 08, 2007 1:53 pm, edited 1 time in total.
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel »

Change all floats to doubles.

"Float" often causes precision error.
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

Also, please remove the solution from the board. It's too much of a spoiler.
dplt
New poster
Posts: 4
Joined: Thu Feb 15, 2007 4:30 pm
Location: Indonesia
Contact:

Post by dplt »

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

better check next time..

sclo, I've done it :)
arsalan_mousavian
Experienced poster
Posts: 111
Joined: Mon Jan 09, 2006 6:19 pm
Location: Tehran, Iran
Contact:

Post 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
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.
Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post 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.
Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Post by Wei-Ming Chen »

I am tired because of many WAs..

Can someone give some strickly I/O?

thanks very much..
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am

Post 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
Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Post 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
Last edited by Wei-Ming Chen on Tue Jul 10, 2007 12:26 pm, edited 1 time in total.
Post Reply

Return to “Volume 112 (11200-11299)”