10709 - Intersection is Not that Easy
Moderator: Board moderators
-
- Guru
- Posts: 647
- Joined: Wed Jun 26, 2002 10:12 pm
- Location: Hong Kong and New York City
- Contact:
10709 - Intersection is Not that Easy
I try solving it by breaking down into cases, but get WA.
Can anyone provide some insightful input/output? Thanks.
I handled the parallel lines, is there more trick cases?
Can anyone provide some insightful input/output? Thanks.
I handled the parallel lines, is there more trick cases?
well, what I do is pretty straight forward, no exceptions for trick cases made:
if LS and LS
if intersect then distance = 0
else distance is minimum of 4 distances between endpoints
if LS and L
if intersect then distance = 0
else distance is minimum of 2 distances of endpoints of LS to the line
if L and L
if intersect then distance = 0
else distance is distance of any endpoint of first line to the second line
All I need are the right formula's for distance(point,point), distance(point, line) and for intersections between linesegments and lines. For example, 2 line segments intersect if and only if for both segments it holds that the end points of the second line segments lie on different sides of the first line segment. But I don't know whether this helps you out....
if LS and LS
if intersect then distance = 0
else distance is minimum of 4 distances between endpoints
if LS and L
if intersect then distance = 0
else distance is minimum of 2 distances of endpoints of LS to the line
if L and L
if intersect then distance = 0
else distance is distance of any endpoint of first line to the second line
All I need are the right formula's for distance(point,point), distance(point, line) and for intersections between linesegments and lines. For example, 2 line segments intersect if and only if for both segments it holds that the end points of the second line segments lie on different sides of the first line segment. But I don't know whether this helps you out....
How to explain the second sample?Maniac wrote:well, what I do is pretty straight forward, no exceptions for trick cases made:
if LS and LS
if intersect then distance = 0
else distance is minimum of 4 distances between endpoints
....
The minimum of 4 distances between endpoints is 1.414***, not the 0.27735 which is the sample output.
-
- New poster
- Posts: 42
- Joined: Fri Jun 13, 2003 3:47 pm
- Location: Dhaka , Bangladesh
- Contact:
can anyone give some i/o
i am getting wa all the time
for this input
i am getting wa all the time

for this input
my program produces:10 10 11 11 L
15 15 19 19 L
0 0 10 0 L
5 5 10 5 L
0 0 1 1 L
-1 1 2 -2 L
0 0 10 0 L
0 0 0 10 L
2 2 5 5 LS
0 3 8 3 L
2 2 5 5 L
0 3 8 3 LS
0 3 8 3 L
5 5 15 15 LS
-8 0 -1 0 LS
0 1 5 5 LS
-8 0 0 8 LS
0 8 0 -8 LS
0 0 10 0 LS
2 2 8 8 LS
0 5 5 0 LS
0 5 5 5 LS
5 6 8 9 LS
1 1 3 9 LS
5 8 5 6 LS
7 7 100 -2 LS
5 5 6 9 END
5 8 6 4 END
0.00000
5.00000
0.00000
0.00000
0.00000
0.00000
2.00000
1.41421
0.00000
0.00000
0.00000
2.66789
2.00000