PRXOR @ 2019-03-19 16:51:41
#include<bits/stdc++.h>
#define inf 9223300000000000000
#define nint long long
using namespace std;
nint a[10011][10011],b[10011];
int n,m,s,t;
nint minn(int a,nint b)
{
if(a<b) return a;
else return b;
}
void bfs(int mi)
{
queue<int> q;
while(!q.empty()) q.pop();
q.push(mi);
while(!q.empty())
{
int now=q.front();
q.pop();
for(int i=1;i<=n;i++)
{
if(a[now][i]!=0)
{
q.push(i);
b[i]=min(b[i],b[now]+1);
}
}
}
return ;
}
nint dinic(int mi,nint money)
{
int cango=0;
if(mi==t)
{
return money;
}
for(int i=1;i<=n;i++)
{
if(a[mi][i]!=0&&b[i]>b[mi])
{
cango+=min(a[mi][i],dinic(i,money));
}
}
return minn(cango,money);
}
int main()
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
cin>>n>>m>>s>>t;
for(int i=0;i<m;i++)
{
int l,r,x;
cin>>l>>r>>x;
a[l][r]=x;
}
bfs(s);
cout<<dinic(s,inf);
return 0;
}
by PRXOR @ 2019-03-19 16:51:59
一直输出0
by Ebola @ 2019-03-19 16:55:17
开一个亿的long long
数组是什么个意思