-->
当前位置:首页 > 题库

PROGRAMMING:Punch in strategy of net red dot

Luz5年前 (2021-05-10)题库469
A tourist attraction, if it is on fire, is called "net red spot". Let's play in the red dot, commonly known as "punch in". The fast (save) Music (money) method of punching in each network red dot is called "strategy". Your task is to find out from a lot of strategies which can punch in each red dot only once and spend the least on the way.
###Input format:
First, the first line gives two positive integers: the number of net red dots $$n $$($$1 < n / Le 200 $$) and the number of paths between net red dots $$M $$. Next, $$M $$line, each line gives two net red points with access, and the travel expenses on this road (a positive integer), in the format of "net red point 1 net red point 2 expenses", where the net red points are numbered from 1 to $$n $; At the same time, it also gives the cost of your home to some red spots. The format is the same. The number of your home is fixed as' 0 '.
The next line gives a positive integer, $$k $, which is the number of strategies to be tested. Next, there are $$k $$lines. Each line gives a strategy to be checked. The format is:
$$n$$ $$V_ 1$$ $$V_ 2$$ $$\cdots$$ $$V_ n$$
Where $$n (< Le 200) $$is the net red number in the strategy, $$V_ I $$is the red dot number on the path. Let's say you start from home, from $$v_ 1 $$to start clock out, and finally from $$V_ Go home.
###Output format:
In the first line, output the number of strategies that meet the requirements.
In the second line, first output the serial number of the strategy (starting from 1) that can punch in only once at each red dot and spend the least on the road, and then output the total cost of the strategy, separated by a space. If the strategy is not unique, the one with the smallest serial number will be output.
At least one effective strategy is guaranteed, and the total travel cost does not exceed $$10 ^ 9 $.
###Input example:
```in
6 13
0 5 2
6 2 2
6 0 1
3 4 2
1 5 2
2 5 1
3 1 1
4 1 2
1 6 1
6 3 2
1 2 1
4 5 3
2 0 2
seven
6 5 1 4 3 6 2
6 5 2 1 6 3 4
8 6 2 1 6 3 4 5 2
3 2 1 5
6 6 1 3 4 5 2
7 6 2 1 3 4 5 2
6 5 2 1 4 3 6
```
###Output example:
```out
three
5 11
```
###Example description:
Article 2, 3, 4 and 6 do not meet the basic requirements of the strategy, that is, they can not start from home, punch in each red dot only once, and return home. So there are three strategies to meet the conditions.
The total cost of the first strategy is: (0 - > 5) 2 + (5 - > 1) 2 + (1 - > 4) 2 + (4 - > 3) 2 + (3 - > 6) 2 + (6 - > 2) 2 + (2 - > 0) 2 = 14;
The total cost of the fifth strategy can be calculated as follows: 1 + 1 + 1 + 2 + 3 + 1 + 2 = 11, which is a more economical strategy;
The total cost of the seventh strategy can be calculated by the same principle: 2 + 1 + 1 + 2 + 2 + 2 + 1 = 11, which is the same as the cost of the fifth strategy, but the serial number is larger, so it is not output.







answer:If there is no answer, please comment