Page 2 of 2

Posted: Thu Feb 22, 2007 9:32 pm
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.

Posted: Thu Mar 01, 2007 4:01 am
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. :)

Posted: Sat Apr 14, 2007 8:51 pm
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?

Posted: Sat Apr 14, 2007 9:04 pm
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.

Posted: Wed Aug 01, 2007 1:53 am
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.