标签:os io for cti ar amp type size
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <string>
#include <iostream>
#include <map>
#include <cstdlib>
#include <list>
#include <set>
#include <queue>
#include <stack>
using namespace std;
const int INF=0xfffffff;
int n,m;
const int maxn=1111;
int level[maxn];
int Map[maxn][maxn];
int last[maxn];
int s,e;
int pig[maxn];
bool bfs()
{
memset(level,0,sizeof(level));
queue<int> q;
q.push(s);level[s]=1;
while(!q.empty()){
int cur=q.front();q.pop();
for(int i=0;i<=n+1;i++){
if(!level[i]&&Map[cur][i]){
level[i]=level[cur]+1;
q.push(i);
}
}
}
return level[e];
}
int Min(int a,int b)
{
return a>b?b:a;
}
int dfs(int x,int val)
{
int tem=val;
if(x==e) return val;
for(int i=0;i<=n+1;i++){
if(level[i]==level[x]+1&&Map[x][i]&&tem){
int t=dfs(i,Min(val,Map[x][i]));
Map[x][i]-=t;Map[i][x]+=t;
// cout<<tem<<endl;system("pause");
// if(t==0) return 0;
tem-=t;
}
}
return val-tem;
}
int solve()
{
int ans=0;int t;
while(bfs()){
while(t=dfs(s,INF)) ans+=t;
}
return ans;
}
int main()
{
while(scanf