高手。帮忙。最大网络流。解决思路

高手。帮忙。。最大网络流。。
高手,有没有看懂这个程序的。。

题目描述:::

Problem2 Ombrophobic Bovines
Description
Jim's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They have decided to put a rain siren on the farm to let them know when rain is approaching. They intend to create a rain evacuation plan so that all the cows can get to shelter before the rain begins. Weather forecasting is not always correct, though. In order to minimize false alarms, they want to sound the siren as late as possible while still giving enough time for all the cows to get to some shelter. 

The farm has F (1 <= F <= 200) fields on which the cows graze. A set of P (1 <= P <= 1500) paths connects them. The paths are wide, so that any number of cows can traverse a path in either direction. 

Some of the farm's fields have rain shelters under which the cows can shield themselves. These shelters are of limited size, so a single shelter might not be able to hold all the cows. Fields are small compared to the paths and require no time for cows to traverse. 

Compute the minimum amount of time before rain starts that the siren must be sounded so that every cow can get to some shelter.
Input
* Line 1: Two space-separated integers: F and P 

* Lines 2..F+1: Two space-separated integers that describe a field. The first integer (range: 0..1000) is the number of cows in that field. The second integer (range: 0..1000) is the number of cows the shelter in that field can hold. Line i+1 describes field i. 

* Lines F+2..F+P+1: Three space-separated integers that describe a path. The first and second integers (both range 1..F) tell the fields connected by the path. The third integer (range: 1..1,000,000,000) is how long any cow takes to traverse it.

Output
* Line 1: The minimum amount of time required for all cows to get under a shelter, presuming they plan their routes optimally. If it not possible for the all the cows to get under a shelter, output "-1".


代码:::

#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

struct nodeE
{int x , y , z;};

const int nx = 410;
const int mx = 3010;
const int Max = 20000;

nodeE E[mx];
bool visited[nx] , first[nx];
int allow[nx][nx] , flow[nx][nx];
int fa[nx] , start[nx] , prev[nx];
int n , m , M , S , T , L , sum;
long Mx , mid , ans , Map[nx][nx];

bool cmp(const nodeE &i , const nodeE &j)
{
  return (i.x < j.x);
}

int min(int a,int b)
{
return (a<b)? a:b;
}

void init()
{
  int down = 0;
 
  //cin>>n>>L;
  n=3;L=4;
  //cout<<n<<L<<endl;
  S = 0;
  T = n * 2 + 1;
  Mx = Max; 
  Mx *= n;
  m = M = 0;
  memset(Map , 0 , sizeof(Map));
  memset(flow , 0 , sizeof(flow));
  memset(allow , 0 , sizeof(allow));
  for (int i = 1 ; i <= n ; ++i)
  for (int j = 1 ; j <= n ; ++j)
  allow[i][j + n] = Max;
allow[S][1]=7;
allow[n + 1][T]=2;

allow[S][2]=0;
allow[n + 2][T]=4;

allow[S][3]=2;
allow[n + 3][T]=6;

  for (i = 1 ; i <= n ; ++i)
  {
  
//cin>>allow[S][i]>>allow[n + i][T];

  m += allow[S][i];
  M += allow[n + i][T];
  }

  E[0].x=1;E[0].y=2;E[0].z=40;
  E[1].x=3;E[1].y=2;E[1].z=70;
  E[2].x=2;E[2].y=3;E[2].z=90;
 E[3].x=1;E[3].y=2;E[3].z=120;
  for (i = 0 ; i < L ; ++i)
  {
// cin>>E[i].x>>E[i].y>>E[i].z;