There will be multiple test cases. The first line of each test case contains three numbersN, E andC whereN (0
Output:
For each test case, there will be one line of output. First, you have to print the case number. If it is possible to sendC secret message fragments from the current status the output will be“possible”. Otherwise, you have to print all pairs of stations (in ascending order) if it is possible send the required message fragments by increasing the frequency channel between any one of them. If it is still impossible, you have to print “not possible”.
Sample Input Output for Sample Input
4 4 5
1 2 5
1 3 5
2 4 5
3 4 5
4 4 5
1 2 1
1 3 5
2 4 5
3 4 1
4 4 5
1 2 1
1 3 1
2 4 1
3 4 1
0 0 0
Case 1: possible
Case 2: possible option:(1,2),(3,4)
Case 3: not possible
Problemsetter: Syed Monowar Hossain
Special Thanks: Abdullah al Mahmud
http://uva.onlinejudge.org/index.php option=com_onlinejudge&Itemid=8&page=show_problem&category=24&problem=2205&mosmsg=Submission+received+with+ID+12258596
刘汝佳新书--训练指南
题意:给定一个有向网络,每条边均有一个容量。问是否存在一个从点1到点N,流量为C的流。如果不存在,是否可以恰好修改一条弧的容量,使得存在这样的流?
分析:先求一次最大流,如果流量至少为C,则直接输出possible,否则需要修改的弧一定是最小割里的弧。依次把这些弧的容量增加到C,然后再求最大流,看最大流量是否至少为C即可。
很可惜,这样写出来的程序会超时,还需要加两个重要的优化。第一个优化是求完最大流后把流量留着,以后每次在它的基础上增广,第二个优化是每次没必要求出最大流,增广到流量至少为C时就停下来。
#include
#include
#include
#include
#include
#include
#include