Skip to content

Instantly share code, notes, and snippets.

View himanshusingh's full-sized avatar

Himanshu Singh himanshusingh

View GitHub Profile
@himanshusingh
himanshusingh / minCostCirculation.cpp
Created March 12, 2013 16:33
Min Cost Circulation using Negative cycle cancelling algorithm.
const int oo = 1e9;
const int MAX_E = 500000;
const int MAX_N = 500;
int cap[MAX_E], flow[MAX_E];
int edges, to[MAX_E];
int cost[MAX_E];
int last[MAX_N], next[MAX_E];
void add_edge(int u, int v, int capacity, int cst)
{
cap[edges] = capacity, flow[edges] = 0, to[edges] = v;