#include /* XYZZY ADVEN Game Solution Method: 1. V steps of Ford Fulkerson 2. If no progress after V steps we have the least-cost path (no cycles) 3. At the Vth cycle, one vertex of every strongly connected component with a negative cycle will be updated. All vertices that are updated are either members of or reachable from a negative cycle. We can set all other vertices to 'infeasible' 4. At the Vth cycle we can also set all edge costs to 0, because we don't care about the cost any more; only connectivity 5. Another V steps tells us if we can reach our goal */ #include #include int cost[101]; int best[101]; int last[101]; char adj[101][101]; char stuff[1000]; int z,i,j,k,m,n,e,progress; main(){ while ((1 == scanf("%d",&n)) && n != -1){ memset(adj,0,sizeof(adj)); memset(last,0,sizeof(last)); for (i=1;i<=n;i++) best[i] = 0x3fffffff; for (i=1;i<=n;i++) { scanf("%d%d",&e,&m); cost[i] = -e; for (j=0;j