In the town there are N crossing points numbered from 1 to N and M two-way roads numbered from 1 to M. Two crossing points can be connected by multiple roads, but no road connects a crossing point with itself. Each sightseeing route is a sequence of road numbers. should be different.The length of the sightseeing route is the sum of the lengths of all roads on the sightseeing route, i.e.. Your program has to find such a sightseeing route, the length of which is minimal, or to specify that it is not possible,because there is no sightseeing route in the town.
There is a travel agency in Adelton town on Zanzibar island. It has decided to offer its clients, besides many other attractions, sightseeing the town. To earn as much as possible from this attraction, the agency has accepted a shrewd decision: it is necessary to find the shortest route which begins and ends at the same place. Your task is to write a program which finds such a route. In the town there are N crossing points numbered from 1 to N and M two-way roads numbered from 1 to M. Two crossing points can be connected by multiple roads, but no road connects a crossing point with itself. Each sightseeing route is a sequence of road numbers y_1, ..., y_k y 1 ,...,y k , k>2. The road y_i (1 leq i leq k-1) y i (1≤i≤k−1) connects crossing points x_i x i and x_{i+1} x i+1 , the road y_k y k connects crossing points x_k x k and x_1 x 1 . All the numbers x_1,...,x_k x 1 ,...,x k should be different.The length of the sightseeing route is the sum of the lengths of all roads on the sightseeing route, i.e. L(y_1)+L(y_2)+...+L(y_k) L(y 1 )+L(y 2 )+...+L(y k )where L(y_i) L(y i ) is the length of the road y_i (1leq i leq k) y i (1≤i≤k). Your program has to find such a sightseeing route, the length of which is minimal, or to specify that it is not possible,because there is no sightseeing route in the town.
标签: HBC51248小幼稚买蛋糕 枚举 尺取法Sightseeing trip题解