Pro.ID21678 TitleThere is a war Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21678 AC0 Submit0 Ratio- 时间&空间限制描述There is a sea. There are N islands in the sea. There are some directional bridges connecting these islands. There is a country called Country One located in Island 1. There is another country called Country Another located in Island N. There is a war against Country Another, which launched by Country One. There is a strategy which can help Country Another to defend this war by destroying the bridges for the purpose of making Island 1 and Island n disconnected. There are some different destroying costs of the bridges. There is a prophet in Country Another who is clever enough to find the minimum total destroying costs to achieve the strategy. There is an architecture in Country One who is capable enough to rebuild a bridge to make it unbeatable or build a new invincible directional bridge between any two countries from the subset of island 2 to island n-1. There is not enough time for Country One, so it can only build one new bridge, or rebuild one existing bridge before the Country Another starts destroying, or do nothing if happy. There is a problem: Country One wants to maximize the minimum total destroying costs Country Another needed to achieve the strategy by making the best choice. Then what's the maximum possible result? 输入There are multiple cases in this problem. There is a line with an integer telling you the number of cases at the beginning. The are two numbers in the first line of every case, N ( 4 ≤ N ≤ 100 ) and M ( 0 ≤ M ≤ n*(n-1)/2 ), indicating the number of islands and the number of bridges. There are M lines following, each one of which contains three integers a, b and c, with 1 ≤ a, b ≤ N and 1 ≤ c ≤ 10000, meaning that there is a directional bridge from a to b with c being the destroying cost. There are no two lines containing the same a and b. 输出Description There is a sea. There are N islands in the sea. There are some directional bridges connecting these islands. There is a country called Country One located in Island 1. There is another country called Country Another located in Island N. There is a war against Country Another, which launched by Country One. There is a strategy which can help Country Another to defend this war by destroying the bridges for the purpose of making Island 1 and Island n disconnected. There are some different destroying costs of the bridges. There is a prophet in Country Another who is clever enough to find the minimum total destroying costs to achieve the strategy. There is an architecture in Country One who is capable enough to rebuild a bridge to make it unbeatable or build a new invincible directional bridge between any two countries from the subset of island 2 to island n-1. There is not enough time for Country One, so it can only build one new bridge, or rebuild one existing bridge before the Country Another starts destroying, or do nothing if happy. There is a problem: Country One wants to maximize the minimum total destroying costs Country Another needed to achieve the strategy by making the best choice. Then what's the maximum possible result? Input There are multiple cases in this problem. There is a line with an integer telling you the number of cases at the beginning. The are two numbers in the first line of every case, N ( 4 ≤ N ≤ 100 ) and M ( 0 ≤ M ≤ n*(n-1)/2 ), indicating the number of islands and the number of bridges. There are M lines following, each one of which contains three integers a, b and c, with 1 ≤ a, b ≤ N and 1 ≤ c ≤ 10000, meaning that there is a directional bridge from a to b with c being the destroying cost. There are no two lines containing the same a and b. Output There is one line with one integer for each test case, telling the maximun possible result. Sample Input 4 Sample Output 0 Source 样例输入4 样例输出0 作者 |