题目链接 有源汇有上下界最小流,-> 上下界网络流 注意细节,边数组也要算上后加到SS,TT边。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cmath> 4 #include<cstring> 5 #include<iostream> 6 7 using namespace std; 8 9 const int N = 150010 ; 10 const int INF = 1e9; 11 12 struct Edge{ 13 int to,nxt,c; 14 }e[ 500100 ]; 15 int head[N],dis[N],cur[N],M[N]; 16 int q[ 500100 ],L,R; 17 int tot = 1 ,n,m,S,T,Sum; 18 19 inline char nc() { 20 static char buf[ 100000 ],*p1 = buf,*p2 = buf; 21 return p1==p2&&(p2=(p1=buf)+fread(buf, 1 , 100000 ,stdin),p1==p2)?EOF:*p1++ ; 22 } 23 inline int read() { 24 int x = 0 ,f = 1 ; char ch = nc(); 25 for (; ch