There are n lotus leaves. On the top of a convex polygon, there is a little frog standing at the point of the 1 lotus leaf. The little frog can jump from the lotus leaf to any other lotus leaves, and the coordinates of N points are given. <800 ask the frog to traverse all the lotus leaves once and only once through the shortest path. If there is no convex polygon, It is the bare TSP problem. The data range cannot be very large, and it can be about n = 20 at most with DP, that is to say, a more advanced annealing simulation algorithm can only reach about 40. However, the point of this question is on a convex polygon, so it has the following properties:
The path traversed by the frog does not overlap.It is easy to prove. Draw a graph and use the sum of the two sides of the triangle to be greater than the third side. Conclusion: A frog can only jump to node 2 or node N at Node 1. If the frog jumps to node 2, the problem is transformed into: Starting from 2, traversing the shortest path of Node 2. N only once. If the frog jumps to node N, the problem is transformed into: Starting from N, traverse the shortest path of Node 2. N once. This is actually a recursive thinking, which converts the problem into a subproblem of the same nature but smaller size. F (S, L, 0) indicates that starting from S, traversing s .. S + L-1 one time and only one time the shortest; F (S, L, 1) indicates starting from S + L-1, traversing s .. S + the Shortest Path of the L-1 once and only once. State transition equation: F [s] [l] [0] = min {f [S + 1] [L-1] [0] + dist [s] [S + 1], f [S + L-1] [L-1] [1] + dist [s] [S + L-1]}; f [s] [l] [1] = min {f [s] [L-1] [1] + dist [S + L-1] [S + L-2], f [s] [L-1] [0] + dist [s] [S + L-1]};
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.