I do simple check to what part does the point below. What's wrong? WA#6. Some tricky tests? Thanks (-)
Послано
Alexey 15 окт 2006 11:23
Edited by author 15.10.2006 11:24
Re: I do simple check to what part does the point below. What's wrong? WA#6. Some tricky tests? Thanks (-)
Check each region by x and y, e.g.
if (b+c<=y && y<=b+c+b && c <= x && x<=c+a) // bottom region
Thanks. Now I have WA#7 )
Послано
Alexey 15 окт 2006 18:59
I had some mistakes like
If y>=a+b+c ...
but must be
If y>=b+b+c
I have one check per one side.
For example
If y<=b - the point is on the lowest side (on the picture).
If x<=c - the point is on the leftest side.
etc.
So, it is enough to check, you see, but WA#7.
Thanks for help but still need it. )
Re: Thanks. Now I have WA#7 )
You need check
y > b+b+c and y < b+c..
because when point on the edge .... You can do mistake ...
(I was wrong in this)
Re: Thanks. Now I have WA#7 )
Послано
Alexey 18 окт 2006 21:28
I have AC, so thank U very much!
But I still don't understand my mistake.
It is guaranted that the point is in the picture, so
I can only check one coordinate...
Cann't understand...
Re: Thanks. Now I have WA#7 )
be careful when you do checks like
if (x <= a) then ...
it can produce WA, becouse if x = a, point can lie on another side
Re: Thanks. Now I have WA#7 )
Yes, that is true.
Thank you.
The test that makes the difference is:
-------
2 2 2
0 4
4 0
-------
before this correction the answer was 4.8989794856 (wrong!)
but the right answer is 2.8284271247 (verifyed with AC program).
Re: Thanks. Now I have WA#7 )
This is great test. Thank you!
Re: Thanks. Now I have WA#7 )
If you use real numbers, you can get situation, when point lies on none of 6 sides. So you should work with epsilon. Or you can use exact arithmetic, just multiply numbers by 100!
It means 100 and !, not 100! :)
Edited by author 26.06.2009 17:41
Re: Thanks. Now I have WA#7 )
TY, Paul Diac!
Edited by author 30.10.2017 01:21