1927: [sdoi2010] interstellar racing time limit: 20 sec memory limit: 259 MB
Submit: 1073 solved: 638
[Submit] [Status] Description10's galaxy racing competition is about to begin. As one of the greatest events in the galaxy, winning the project is undoubtedly a dream of many people. The long journey from Jason's alpha star is also one of them. The competition consists of N planets and M two-way interstellar routes, each of which has a different gravity value. The competition required drivers to depart from a celestial body without any route between the N planets, access each of the N planets exactly once, and first win the goal. Since the competition was very open, many people were driving amazing self-made racing cars. This leisurely-driving racing car is called the super-energy donkey, a fantasy racing car that integrates the most advanced technology of the galaxy. As the product of the highest technology, superenable donkey has two kinds of mobile modes: High-Speed sailing mode and capability explosion mode. In the high-speed sailing mode, superenable donkey expands the anti-material engine, sailing at a speed that is several times faster than the speed of light along the Star Trek Expressway. In the capability explosion mode, the super-powered e-ass breaks away from the limitations of time and space and uses super power to jump between spaces-after a period of positioning, it can instantly move to any planet. The day before the competition, the super-powered electric donkey was unfortunately damaged in an ionic storm, causing some functional obstacles: when using the high-speed sailing model, each planet can only fly to a planet with a greater gravity. Otherwise, a racing car will blow up. Despite a problem with the car you love, you still firmly believe that you can win. He found the smartest sage in the galaxy-you. Please arrange a game plan for him so that he can finish the game in the least time. The first line of input is two positive integers n, m. Number of N in the second row A1 ~ An, where AI indicates the positioning time required to use the capability outbreak mode to reach planet I. In the next M line, each row contains three positive integers, namely, UI, VI, and WI, which indicate that the planet numbered UI and VI is stored in an interstellar route that requires wi time. The input data has been sorted by the gravity value, that is, the gravity value of a planet with a small number must be small, and there will be no two planets with the same gravity value. Output contains only one positive integer, indicating the minimum time required to complete the competition. Sample input3 3
1 100 100
2 1 10
1 3 1
2 3 1 sample output12hint
Note: first, use the capability outbreak mode to go to planet 1, which takes 1 time.
Then switch to the high-speed sailing mode and navigate to planet 2, which takes 10 minutes.
And then continue sailing to planet 3 to complete the competition, taking time 1.
Although it looks better from Planet 1 to planet 3 to planet 2, we cannot do that because
This will lead to an explosion of superenable donkeys.
For 30% of data, n ≤ 20, m ≤ 50;
For 70% of data, n ≤ 200, m ≤ 4000;
For 100% of data, n ≤ 800, m ≤ 15000. The number of input data cannot exceed 106.
.
Input data ensures that at most one channel exists between any two planets, and no planet exists
Your own channels.
Source
Day2 in the first round
Problem: DP abused and cried, and a network flow came into the water... Let's talk about the composition of this question: 1. split each vertex into two vertices I. I + N2. create an additional source ss. The capacity of the SS to I + N is 1, and the cost is the edge of the time required for the capability explosion. the connection capacity from S to I is 1 and the cost is 0. edge 5 with a capacity of 1 from I + n to T and a cost of 0. if X to Y exists in the source image, and x <Y, then an X to Y + N is connected. The capacity is 1, the maximum cost is the sum of the time required to take this path. The biggest flow is the answer, so that you can submit the graph to the AC, but why do you create a graph like this? I am not clear about it. I suggest you stick to the question of jry. ------------------- it is similar to the minimum path coverage, but it should be charged. Because it can be overwritten, the billing flow ensures that a path overwrites all vertices. This is the enhanced version with the minimum path coverage. Split each vertex into two vertices. If I have one edge from J, I will connect I1 to J2 with an edge with a fee of 1 and the traffic will be directed from the source to each I1, the result of a fee flow is the answer. In the beginning, I am very sb. I used instant migration as an EDGE connection, and then it is a mess. In fact, as long as the source connects to each I2, the traffic is 1, and the fee is the instant migration time, simple and rude, just AC. Certificate --------------------------------------------------------------------------------------------------------------------------------------------------