Original: http://972169909-qq-com.iteye.com/blog/1184514
Title Address: here.
1) The minimum value of the total length of all rings in the graph (the length of the ring is not unique) . The description ring does not exist when a complete match cannot be obtained.
Question three:http://acm.hdu.edu.cn/showproblem.php?pid=1853
Directly build the map, pay attention to the heavy side Oh!
if (-C > W[a][b])
W[A][B] =-C;
When the wood has the perfect match output-1
Question fourth:http://acm.hdu.edu.cn/showproblem.php?pid=3488
Almost the same as the third question.
question fifth:http://acm.hdu.edu.cn/showproblem.php?pid=3435
basically the same as the third question code, just to two-way map, there are heavy edges
Question seventh: http://acm.hdu.edu.cn/showproblem.php?pid=2853
The main idea: there are now N troops and M missions (M>=N), each force to complete each task is a little more efficient, the higher the better. But the troops have arranged a certain plan, then we need to use the smallest change, so that all the force of the most efficient. The difference between the number of minimum changes and the efficiency before and after the change.
Ingenious idea:
Because we want to change the smallest, so to the side of the original plan to have some special care, so that the best match, as far as possible priority to use the original side, so that the change can be minimal and will not affect the original match.
According to this idea, we can enlarge the weights of each edge by K times, and K to be greater than N. Then +1 on the side of the original plan. The essence is all here. Let us elaborate.
All edges are enlarged k times, and K is larger than N, so that the best match we find is the maximum weight of k times, as long as the maximum weight can be obtained by dividing by K. Achieve the original side plus 1, so that each time you select the edge, these changes have an advantage, you will prefer these edges. If the original H-bar is chosen for the optimal match, the optimal weight is the maximum weight of K-+k (1 for each edge of the original plan). But what is the purpose of k greater than n? We found that if all of the original side in the match, will only increase n, and n<k, so divided by K will not affect the best match the sum of the maximum weight, and then we to the K-remainder, just get the number of the planned side to join. At this point, we only need to use the total number of points-added to the original plan points, you can find the minimum change.
Set the result is res
Maximum value: res/100
Minimum number of changes: n-res%100 (res%100 indicates an edge in the original match)
< Span style= "color:red;" > < Span style= "color:red;" > 15th question: http://acm.hdu.edu.cn/showproblem.php?pid=3315
The default match is W[i][i]
si win xj,w[i][j] = V[i]
ownership value expanded 100 times times, w[i][i]++ first match
< Span style= "Color:green;" > < Span style= "Color:green;" > < Span style= "color: #000000;" > similarity = (res%100*100/n)% < Span style= "Color:green;" > < Span style= "Color:green;" > < Span style= "Color:green;" >
Question eighth: http://acm.hdu.edu.cn/showproblem.php?pid=3718
The topic asks for the maximum similarity between two strings.
Idea: Because one letter of the first string can only match one letter of the second string, it can be translated into
"Maximum matching value of letters/n"
Map: "Example"
11th: http://acm.hdu.edu.cn/showproblem.php?pid=2282
Build: The extra 1 calculates the minimum distance with all 0, for example 3, 2 more 1, to match them with all 0, the left set is 1, the right set is the n number "limit match condition (=0) can be"
the number of left set is M, indicating how many 1 need to move
< Span style= "Color:violet;" > question 12th: http://acm.hdu.edu.cn/showproblem.php?pid=2813
You can use trie+km or map+km or hash +km.
Question 13th:http://acm.hdu.edu.cn/showproblem.php?pid=2448
The main idea: there are M mines on the Sea, N ships and ports, the N<=m,n ship is parked in n mines, there is a distance between mine and mine, and there is a distance between mine and port. Now I want you to take the boat back to the port, each port can only stop a boat, ask you how to stop can make the shortest distance of the boat travel?
Problem-Solving ideas:spfa+km, that is, the first ship to stop the mine as the starting point, to do the shortest path of n times, respectively, from the source point to the shortest path to the port, this as their weight, then the KM algorithm to find the minimum right matching is good.
Question nineth:http://acm.hdu.edu.cn/showproblem.php?pid=3722
Directly according to the topic requirements of the map, note that the value of the match with yourself is 0,w[i][i]=0
Question tenth:http://acm.hdu.edu.cn/showproblem.php?pid=3395
Directly according to the topic requirements to build the map can be
< Span style= "Color:violet;" >
question 14th:/http acm.hdu.edu.cn/showproblem.php?pid=2236
Test instructions: In the matrix of NXN, there is no line to find an element, each element is not the same column, the maximum value of the N element-minimum value of the minimum difference
Idea: Violent enumeration difference " Because the value of the element 0<= x <=100, the range of the difference can only be [0,100] "
Hungarian test can be
bool KM (int low, int.)
{
int i;
memset (Match,-1, sizeof (match));
for (i = 0; i < n; i++)
{
Memset (Vis, false, sizeof (VIS));
if (!dfs (i, low, high))
return false;
}
return true;
}
KM Algorithm summary:
When you need to ask for a maximum value, if you can use two-point map, then ...
KM algorithmic topics