Skip to main content

Posts

Showing posts with the label mincut

Minimum cost Maxflow or mincut maxflow or Successive Shortest Path source code in C++

when there is need of minimum cost along with maximum flow then comes this problem. Sometimes it called successive shortest path . Here is a problem for better understanding 10498 ************************************************************************************* #include<iostream> #include<string> #include<vector> #include<queue> #include<algorithm> using namespace std; #define MV 102 typedef long long LL; LL  cst[MV][MV],     cap[MV][MV],     par[MV],dis[MV],     source,sink,flow; vector<int>adj[MV]; struct pq{     LL d,n;     void ini(LL a,LL b){n=a;d=b;}     bool operator<(const pq &b)const{return d>b.d;} }; bool PFS(int s,int sk) {     priority_queue<pq>Q;     pq u,v;     int i;     memset(dis,50,sizeof dis);     di...