論卡常的重要性
評測記錄。。。
卡常前。。。
卡常後。。。
竟然。。。就a了!!!!
有無限只兔子在左上角,現在它們要走到右下角,之間有很多通道,但通道只能容納一定數量的兔子,狼可以在一定道路堵截兔子,乙隻狼只能堵截一條兔子,求能堵截所有兔子的狼數。
這道題就是就相當於求最小割,按照這張圖上說的建圖差不多就得了
記得反向邊的容量也要為k,因為這是無向圖!
似乎這道題也能用sp
fas pf
a過,但本蒟蒻太弱(lan)就沒打了。。。
#include
#include
#include
#define n 3500001
#define id(i,j) (~-i)*m+j
using
namespace
std;int m,n,f,s,t,sum,k;char c;
struct nodee[n<<1];
int l[n],tot,d[n];
int read()
void add(int u,int v,int w)
;l[u]=tot++;
e[tot]=(node);l[v]=tot++;
return;
}bool bfs()}}
return
false;
}int dfs(int x,int flow)
//這裡很重要
e[i].w-=f;rest+=f;e[i^1].w+=f;
if(rest==flow) return flow;//這裡也是
}return rest;
}void dinic()
int main()
最小費用最大流(SPFA版本)
1 include 2 include 3 include 4 include 5 6using namespace std 78 define ll long long 9 define pb push back 10 define fi first 11 define se second 121...
BZOJ 1001狼抓兔子(最大流)
description 現在小朋友們最喜歡的 喜羊羊與灰太狼 話說灰太狼抓羊不到,但抓兔子還是比較在行的,而且現在的兔子還比較笨,它們只有兩個窩,現在你做為狼王,面對下面這樣乙個網格的地形 左上角點為 1,1 右下角點為 n,m 上圖中n 4,m 5 有以下三種型別的道路 1 x,y x 1,y 2...
模板 SPFA增廣 最小費用最大流
簡單的用spfa增廣進行費用流的求解 與ek求最大流類似,只是此時要求最大流的同時費用最小 所以用spfa增廣,就可以費用盡量小 模板 include include include using namespace std const int maxn 705,maxe 144005,inf 0x3...