#P6085. [JSOI2013] 吃货 JYY
[JSOI2013] 吃货 JYY
Description
There are cities in the world that JYY is willing to visit, numbered from to . JYY selected flights that he must take. Besides these, there are flights that JYY has no special preference for; he may take them or not.
We represent a flight with a triple , meaning that this flight connects city and city , and the ticket cost is . Each flight is round-trip, so after paying , JYY can choose to fly from to or from to .
Nanjing is numbered as . Now JYY plans to start from Nanjing, take all flights, and finally return to Nanjing. Please help him find the minimum total cost.
Input Format
The first line contains two integers and .
The next lines each contain three integers , describing the flights that must be taken. The testdata guarantees that among these flights, there are no two different flights operating between the same pair of cities.
Line contains an integer . The next lines each contain three integers , describing the flights that may be taken or not.
Output Format
Output one line containing one integer, representing the minimum total cost. The testdata guarantees that there exists at least one travel plan satisfying JYY’s requirements.
6 3
1 2 1000
2 3 1000
4 5 500
2
1 4 300
3 5 300
3100
Hint
Sample Explanation
One feasible optimal plan is $1\rightarrow 2\rightarrow 3\rightarrow 5\rightarrow 4\rightarrow 1$.
The ticket cost is .
Constraints
For of the testdata, $2\leq N\leq 13,0\leq K\leq 78,2\leq M\leq 200,1\leq x,y\leq N,1\leq z\leq 10^4$。
Translated by ChatGPT 5
京公网安备 11011102002149号