ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1647. Divide an Island!

Shteiner, Tyurin, Dergachev WA#1 [11] // Problem 1647. Divide an Island! 25 Oct 2008 17:00
Why? I pass the given tests correctly.

BTW, the problem can have several answers, :S
Al.Cash Re: WA#1 [10] // Problem 1647. Divide an Island! 25 Oct 2008 17:48
I had WA#1, then WA#22. Can somebody help me? I think there are problems with precision.
Shteiner, Tyurin, Dergachev Re: WA#1 [7] // Problem 1647. Divide an Island! 25 Oct 2008 18:00
Wow, I also have WA#22 now.

BTW, my WA#1 was because I didn't #include <math.h> LOL
Al.Cash Re: WA#1 [6] // Problem 1647. Divide an Island! 25 Oct 2008 18:01
AC now)))
Using epsilon in some more places helped me a lot!
svr Re: WA#1 [5] // Problem 1647. Divide an Island! 26 Oct 2008 09:52
Yes!Agree.Impossible get Ac without eps.
Aram Shatakhtsyan Epsilon [4] // Problem 1647. Divide an Island! 27 Oct 2008 01:02
Please, who can explain me why epsilon is needed in
problems which contain real numbers, and where should
I use it in this problem? I got WA#22, and can't
understand my mistake.
svr Re: Epsilon [3] // Problem 1647. Divide an Island! 27 Oct 2008 09:44
There are many trick with epsilon.
For example. Let eps=1e-10 and some geometrical
value d calculated as -1.e-11. We reject this
calculation because d must be >=0 and make mistake
lossing d=0. With eps we do it as
if (fabs(d)<=eps) d=0
thus accepting negative -1e-11.
Partisan Re: Epsilon [2] // Problem 1647. Divide an Island! 3 Sep 2009 21:36
When I used eps=1e-13, I got WA #22, and when I chaged it to 1e-10, I got AC.

Here are fragments, where I use eps:

...
double d=p*p-2*a*b;
if(fabs(d)<eps)
...
(d is discriminant of square equation)

...
if(t1>a+eps || t2>b+eps)
    return false;
...
(check that t1<=a and t2<=b).

I can't understand why I had this situation.
Partisan Re: Epsilon // Problem 1647. Divide an Island! 5 Sep 2009 01:08
Maybe the numbers are big, so adding 1e-13 is equal to adding 0.
timus__dimus Re: Epsilon // Problem 1647. Divide an Island! 30 Jul 2011 02:05
eps = 1e-10
thanks!

Edited by author 30.07.2011 02:06

Edited by author 30.07.2011 02:06
Chiffa Re: WA#1 [1] // Problem 1647. Divide an Island! 25 Oct 2008 18:02
According formule S=sqrt(p*(p-a)*(p-b)*(p-c)) => the problem has 3 different answers.
Al.Cash Re: WA#1 // Problem 1647. Divide an Island! 25 Oct 2008 18:08
No! Sample #2 has only one answer.