#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dwn(i,a,b) for(int i=(a);i>=(b);i--)
const int N=210,M=5e3+10;
int _map[M][M],pre[M];
int vis[M];
int n,m,s,t;
void _update_(int u,int flow)
{
while(pre[u]!=-1)
{
_map[pre[u]][u]-=flow;
_map[u][pre[u]]+=flow;
u=pre[u];
}
}
int _find_path_(int s,int t)
{
memset(vis,0,sizeof vis);
memset(pre,-1,sizeof pre);
vis[s]=1;
int min_flow=1e9+10;
queue<int>q;
q.push(s);
while(!q.empty())
{
int u=q.front();q.pop();
if(u==t)break;
rep(i,1,m)
{
if(vis[i]==0&&_map[u][i]!=0)
{
q.push(i);
min_flow=min(min_flow,_map[u][i]);
pre[i]=u;
vis[i]=1;
}
}
}
if(pre[t]==-1)return 0;
return min_flow;
}
int _EK_(int s,int t)
{
int new_flow=0,max_flow=0;
do{
new_flow=_find_path_(s,t);
_update_(t,new_flow);
max_flow+=new_flow;
}while(new_flow!=0);
return max_flow;
}
int main()
{
cin>>m>>n;
rep(i,1,m)
{
int u,v,w;
cin>>u>>v>>w;
_map[u][v]=w;
}
int ans=_EK_(1,n);
cout<<ans;
}
wa#2,#12
请大佬们帮忙看看,谢谢