11168 - Airport

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

Moderator: Board moderators

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo »

Vexorian wrote:Thanks for your help everyone.

It was a very silly thing indeed.

Turns out that in some place I was doing printf("%0.3lf",0); as a rushed modiffication to handle some special cases.

But 0 is not a double, it is an integer, so the code was actually undefined, it could pretty much generate random numbers depending on the situation.

I was not able to find this before because the special cases were just in the input after some cases that already returned 0.000 , so the random bytes were assigned to zero.

But there it is.
I think if you do printf("%.3lf",0LL); it works properly since double and long long are both 64 bits.
Abednego
A great helper
Posts: 281
Joined: Tue Sep 10, 2002 5:14 am
Location: Mountain View, CA, USA
Contact:

Post by Abednego »

Vexorian wrote: Turns out that in some place I was doing printf("%0.3lf",0); as a rushed modiffication to handle some special cases.
Always compile your code with the -Wall flag. :)
If only I had as much free time as I did in college...
LithiumDex
New poster
Posts: 44
Joined: Tue Jun 06, 2006 6:44 pm
Location: Nova Scotia, Canada
Contact:

Post by LithiumDex »

you need to calculate the average distance to a line in O(1) time
how the heck are you supposed to do that? I've been searching the internet for hours, and can't find anything.. care to give a better hint?
- Chris Adams
Abednego
A great helper
Posts: 281
Joined: Tue Sep 10, 2002 5:14 am
Location: Mountain View, CA, USA
Contact:

Post by Abednego »

LithiumDex: what he means by "O(1) time" is "amortized O(1) time". FIrst, you do some expensive precomputation, and then you use it to answer questions of the form, "What's the average distance to line L?" in O(1) time per question.
If only I had as much free time as I did in college...
sonyckson
New poster
Posts: 49
Joined: Tue Feb 06, 2007 9:29 pm
Location: Cordoba, Argentina

Post by sonyckson »

hello, i have been trying to solve this problem.. but i got many WA's because of overflowing... after i solved that problem... and testing rio's cases of this thread i thought i would have no problems.. but now im getting time limit exceeded... is it for my O(n^2) convex hull algorithm?.. in my computer it runs very fast for 10000 points... but perhaps there are many test cases.. anyone could solve it with an O(n^2) algorithm? ( I get the distances to an "edge" in O( 1 ).. ) thanks. eric.
Post Reply

Return to “Volume 111 (11100-11199)”