ICPC East Central NA Regional Contest 2005, Problem E
You're in charge of designing a campus network between buildings and are very worried about its reliability and its cost. So, you've decided to build some redundancy into your network while keeping it as inexpensive as possible. Specifically, you want to build the cheapest network so that if any one line is broken, all buildings can still communicate. We'll call this a minimal reliable net.
Input Specification
There will be multiple test cases for this problem. Each test case will start with a pair of integers and on a line indicating the number of buildings (numbered 1 through ) and the number of potential inter-building connections, respectively. (Values of indicate the end of the problem.) The following lines are of the form (all positive integers) indicating that it costs to connect building and . All connections are bidirectional.
Output Specification
For each test case you should print one line giving the cost of a minimal reliable net. If there is a minimal reliable net, the output line should be of the form:
The minimal cost for test case p is c.
where is the number of the test case (starting at 1) and is the cost. If there is no reliable net possible, output a line of the form:
There is no reliable net possible for test case p.
Sample Input
4 5
1 2 1
1 3 2
2 4 2
3 4 1
2 3 1
2 1
1 2 5
0 0
Sample Output
The minimal cost for test case 1 is 6.
There is no reliable net possible for test case 2.
Comments