Test
New Title 1
New Title 2
New Title 3
New Title 4
New Title 5
New Title 6
####### New Title 7
g++ a.cpp -o run.out -std=c++11 -wall -Wextra
\(L^AT_EX\)
include
\(\sqrt{\sum\limits_1^{\sum\limits_1^2 ddd} asdfasf}\)
\[{\frac a b} {a \over b}{a \above 0.4pt b} {a \above 0.5pt b}
\]
©
- 222
- 223
- 232
4. 233
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
viverra nec, fringilla in, laoreet vitae, risus. - Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
Suspendisse id sem consectetuer libero luctus adipiscing.
This is an example inline link.
[] a
aijfskalf
fkjajfjsa
//一道网络流= =
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
#define rep(i,l,r) for(register int i=(l);i<=(r);++i)
#define repdo(i,l,r) for(register int i=(l);i>=(r);--i)
typedef double db;
typedef long long ll;
//---------------------------------------
const int ninf=(int)1e9+500,nsz=(int)1e4+5000,esz=(int)1e5+5000;
int n,m,line[60][60],sum=0;
//network flow
struct te{int t,pr,fl;}edge[esz*2];
int hd[nsz],pe=1,np,ss,tt;
void adde(int f,int t,int fl){edge[++pe]=(te){t,hd[f],fl};hd[f]=pe;}
void addsg(int f,int t,int fl){adde(f,t,fl);adde(t,f,0);}
void adddb(int f,int t,int fl){adde(f,t,fl);adde(t,f,fl);}
int d[nsz],gap[nsz],cur[nsz];
void init(){
static int que[nsz],qh,qt;
qh=1,qt=0;
que[++qt]=tt,d[tt]=1,gap[1]=1;
while(qh<=qt){
int u=que[qh++];
for(int i=hd[u],v=edge[i].t;i;i=edge[i].pr,v=edge[i].t){
if(d[v])continue;
d[v]=d[u]+1,++gap[d[v]];
que[++qt]=v;
}
}
rep(i,1,np)cur[i]=hd[i];
}
int dfs(int p,int mi){
if(mi==0||p==tt)return mi;
int fl=0,tmp;
for(int &i=cur[p],v=edge[i].t;i;i=edge[i].pr,v=edge[i].t){
if(d[v]+1!=d[p])continue;
tmp=dfs(v,min(edge[i].fl,mi));
fl+=tmp,mi-=tmp,edge[i].fl-=tmp,edge[i^1].fl+=tmp;
if(mi==0)return fl;
}
if(gap[d[p]]==1)d[ss]=np+1;
--gap[d[p]],++d[p],++gap[d[p]];
cur[p]=hd[p];
return fl;
}
int maxfl(){
int res=0;
init();
while(d[ss]<=np)res+=dfs(ss,ninf);
return res;
}
int main(){
// ios::sync_with_stdio(0),cin.tie(0);
cin>>n>>m>>ss>>tt;
np=n;
int a,b,c;
rep(i,1,m)cin>>a>>b>>c,addsg(a,b,c);
cout<<maxfl()<<'\n';
return 0;
}