E :: Mothy
Time Limit: 5 Seconds Memory Limit: 65536 KB
Mothy is a small moth. Mothy and his mother are placed on a very old
pair of jeans. Because the jeans are very old they are covered with
patches. Sometimes the patches overlap each other. Every patch is a
convex polygon and is made by some material different from cotton. Mothy
wants to go to his mother in the fastest possible way. He cannot move
without eating and because of his age he cannot eat anything except
jeans and cotton thread. Despite his age Mothy is very intelligent, he
can move following precise coordinates but he is unable to compute them.
Write a program that calculates the length of the minimal path from the
position of Mothy to the position of his mother. Mothy must be able to
pass through this path. Consider that the pair of old jeans is placed on
a plane surface and is big enough. Mothy can move only at the surface
of the jeans because he is not big enough to penetrate through them.
Because Mothy is so small he should be considered as a point. Mothy
also can move on the edges of any of the patches because they are sewed
with cotton threads. Mothy can move on common edges but cannot be on top
of any patch.
Input
Output
Sample Input
2 1 0 0 4 3 3 1 1 4 4 1 4 2 0 0 5 5 4 1 0 4 0 4 1 1 2 3 3 3 4 4 5 2
Sample Output
5.000 7.236Submit