text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
struct SuccessiveShortestPath {
struct Edge{ int to, cap, cost, rev; };
int n, init;
vector<vector<Edge>> g;
vector<int> dist, pv, pe, h;
SuccessiveShortestPath() {}
SuccessiveShortestPath(int n, int INF = 1e9)
: n(n), g(n), init(INF), dist(n), pv(n), pe(n... |
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
long long primal_dual(vector<map<int, pair<long long, int>>> &E, int s, int t, long long F){
int V = E.size();
for (int i = 0; i < V; i++){
for (auto edge : E[i]){
if (!E[edge.first].count(i)){
E[edge.first][i] = make_pair(0, -ed... |
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
struct min_cost_flow_graph_bellman_ford {
struct edge {
int from, to;
T cap, f;
U cost;
};
vector<edge> edges;
vector<vector<int>> g;
int n, st, fin;
T required_flow, flow;
U cost;
min_cost_flow_graph_bellman_ford(int n... |
#include <bits/stdc++.h>
using namespace std;
int v, e;
vector<pair<int, int> > adj[110], revadj[110];
int capacity[1010], cost[1010], flowingthrough[1010], dis[110], pre[110], preedge[110], endofedge[1010];
void bellmanford()
{
fill_n(dis, v, 1e9);
dis[0] = 0;
for (int f = 0; f < v; f++)
{
for (int i = 0; i < v;... |
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
tem... |
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)
#define MAX_V 100
stru... |
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
template<typename flow_t = int, typename cost_t = int>
struct PrimalDual {
const cost_t INF;
struct edge {
int to;
flow_t cap;
cost_t cost;
int rev;
bool is... |
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(n);i++)
struct edge {
ll to;//行き先の頂点
ll cap;//辺の容量
ll cost;//1フローあたりのコスト
ll rev;//逆辺のインデックス(G[e.to][e.rev]で逆辺にアクセスできる。)
};
#define MAX_V 1000
#define... |
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct PrimalDual{
const int INF = 1<<28;
typedef pair<int,int> P;
struct edge{
int to,cap,cost,rev;
edge(){}
edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};
int n;
vector<vector<... |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;
const double EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = 2e5;
const double PI = acos(-1.0);
using namespace std;
struct MinCostFlow {
str... |
#include <iostream>
#include <vector>
#include <numeric>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
const int MAX_V = 100010;
using Flow = int;
const auto inf = numeric_limits<Flow>::max() / 8;
struct Edge {
int dst;
Flow cap, cap_orig;
Flow cost;
... |
#include <iostream>
#include <vector>
#include <queue>
#include <limits>
using namespace std;
template <typename T>
class MinCostFlow
{
public:
MinCostFlow(int n) : n(n), capacity(n, vector<T>(n)), cost(n, vector<T>(n)), prev(n) {}
void add_edge(int src, int dst, T cap, T c)
{
capacity[src][dst] = cap;
... |
#include <cstdio>
#include <vector>
#include <queue>
#include <tuple>
int v, e;
struct Edge {
Edge() {}
Edge(int from, int to, int capacity, int cost, int rev) : from(from), to(to), capacity(capacity), cost(cost), rev(rev) {}
int from, to;
int capacity;
int cost;
int rev;
};
std::vector<Edge> edges[128];... |
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
// BEGIN CUT HERE
template<class T> struct PrimalDual {
struct Edge { int to, rev; T cap, cost; };
const T inf = numeric_limits<T>::max();
const int n;
... |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)
#define MAX_V 100
struct edge { int to, cap, cost,rev; };
int V; // ????... |
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 99999999
using namespace std;
typedef int Weight;
struct Edge {
int src, dst... |
#include <bits/stdc++.h>
using namespace std;
template <typename Cap, typename Cost>
struct Graph {
const Cost INF = numeric_limits<Cost>::max();
struct Edge {
int to, rev;
Cap cap;
Cost cost;
Edge(int to, Cap cap, Cost cost, int rev)
: to(to), cap(cap), cost(cost), rev(rev) {}
};
vector<... |
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//#include "MyMath.h"
//#include "MyDisjointset.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
typedef pair<int, int> P; typedef l... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
struct min_cost_flow_graph {
struct edge {
int from, to;
T cap, f;
U cost;
};
vector<edge> edges;
vector<vector<int>> g;
int n, st, fin;
T required_flow, flow;
U cost;
min_cost_flow_graph(int n, int st, int fin, T requi... |
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define r... |
#include <iostream>
#include <vector>
#include <queue>
#define INF (1 << 30)
using namespace std;
struct Edge {
//to : Edge(from ??? to) cap:capacity cost:cost rev:reverse
int to, cap, cost, rev;
Edge(int to, int cap, int cost, int rev) :to(to), cap(cap), cost(cost), rev(rev) {}
};
#define P vector<vector<Edge>>
... |
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef ... |
//#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <util... |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include... |
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;
const int maxq=1005;
struct edge{int to,cap,cost,rev;};
int n,m,k;
int d[maxn];
int a[maxn];
int p1[maxn];
int p2[maxn];
bool inq[maxn];
vector<edge>G[maxn];
void add_edge(int u,int v,int c,int w) {
G[u]... |
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#define NMAX 110
#define CMAX 1000000007
using namespace std;
typedef pair<int, int> pii;
int c[110][110] = {0};
int d[110][110] = {0};
int dist[110];
int path[110];
int Dijkstra(vector<int> *g, int s, int t){
priority_queue<pair<int, pii>, v... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< "... |
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES
#include<math.h>
#include<map>
#define INF 200000000
using name... |
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;
const int maxq=1005;
struct edge{int to,cap,cost,rev;};
int n,m,k;
int d[maxn];
int a[maxn];
int p1[maxn];
int p2[maxn];
bool inq[maxn];
vector<edge>G[maxn];
void add_edge(int u,int v,int c,int w) {
G[u]... |
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX_V 10000
#define INF 1000000001
typedef pair<int,int> P;
struct edge { int to,cap,cost,rev; };
int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
void init_edge(){
for(in... |
#include "bits/stdc++.h"
using namespace std;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
static const int INF = 0x3f3f3f3f;
struct edge {
int to, cap, cost, rev;
};
int V;
vector<edge> g[1010... |
#include "bits/stdc++.h"
using namespace std;
class minCostFlow
{
using type = int;
using pii = std::pair<int, int>;
const int INF = 1e9;
struct Edge
{
type to, cap, cost, rev;
Edge(type to_, type cap_, type cost_, type rev_)
: to(to_), cap(cap_), cost(cost_), rev(rev_)... |
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;
struct edge{int to,cap,cost,rev;};
int n,m,k;
int d[maxn];
int a[maxn];
int p1[maxn];
int p2[maxn];
bool inq[maxn];
vector<edge>G[maxn];
void add_edge(int u,int v,int c,int w) {
G[u].pb(edge{v,c,w,int(G[... |
// this program implements Dinitz's algorithm
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
const int N = 110;
const int M = 2010;
const int inf = 0x3fffffff;
struct Edge {
int to, cap, cost, next;
} es[M];
int S, T; // source, sink
int SIZE = 0; // number of edges
int h[N]; // poin... |
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 100000... |
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ZERO(a) memset(a,0,sizeof(a))
template<int NV, class V> class MinCostFlow {
public:
struct edge {
int to, capacity; V cost; int reve;
edge(int a, int b, V c, int d) {
to = a; capacity = b; cost = c; reve = d;
}
};... |
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline void chmin(A &a,B b){if... |
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
#define ALL(a) begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend... |
/*
負の閉路が存在しない場合に使える
O(FElogV)
参考:
蟻本p202
https://ei1333.github.io/luzhiled/snippets/graph/primal-dual.html
verify:
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp
*/
#include <bits/stdc++.h>
using namespace std;
template<typename flow_t,typename cost_t>
struct PrimalDual{
struct edge{
... |
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << end... |
#include <iostream>
#include <vector>
#include <limits>
template <class Cap, class Cost, bool isDirect>
class MinCostFlow {
struct Edge {
int from, to;
Cap cap;
Cost cost;
int rev;
Edge(int from, int to, Cap cap, Cost cost, int rev)
: from(from), to(to), cap(cap)... |
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES
#include<math.h>
#include<map>
#define INF 200000000
using name... |
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#includ... |
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
using namespace std;
int v,e,f;
unordered_map<int,unordered_map<int,int> > g,costs,inv_costs;
queue<pair<int,int> > nodes;
int cost = 0;
int dfs(int now, int flow, vector<bool> &arrived, vector<int> &dp) {
if(now==0||flow==0) return flo... |
#include <bits/stdc++.h>
using namespace std;
const int INF = (int) 1e5 + 1;
const int MAX_V = (int) 100;
struct edge { int to, cap, cost, rev; };
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];
void add_edge(int from, int to, int cap, int cost) {
G[from].push_back( (edge) { to, cap, ... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i = 0; i < (int)(j); i++)
constexpr int INF = 1 << 28;
struct Edge {
int to;
ll capacity, cost, rev;
};
constexpr ll INFL = 1LL << 60;
struct Flow {
int N;
vector<vector<Edge>> E;
Flow(int n) : N(n) {
... |
#include <iostream>
#include <vector>
#include <numeric>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
using Flow = int;
template<typename Flow = int>
struct PrimalDual {
struct Edge {
int dst;
Flow cap, cap_orig;
Flow cost;
in... |
bool debug=false;
#include <string.h>
#include <stdio.h>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
#define F first
#define S second
#define PB push_back
const int INF=1e9+10;
const int N=1e2+10;
pair<int,int> graph[N][N];
pair<int,int> dis[N];
int from[N];
int n;
int min(int a,int b){re... |
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define... |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#... |
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<char> VB;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i... |
//最小費用流問題を解く
//計算量O(F|V||E|)
//参考 蟻本
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
struct edge {
ll to;//行き先の頂点
ll cap;//辺の容量
ll cost;//1フローあたりのコスト
ll rev;//逆辺のインデックス(G[e.to][e.rev]で逆辺にアクセスできる。)
};
#define MAX_V 1000
#define ... |
#include <cstdio>
#include <vector>
#include <queue>
#include <tuple>
int v, e;
struct Edge {
Edge() {}
Edge(int from, int to, int capacity, int cost, int rev) : from(from), to(to), capacity(capacity), cost(cost), rev(rev) {}
int from, to;
int capacity;
int cost;
int rev;
};
std::vector<Edge> edges[128];... |
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const i... |
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;
struct edge{
int to;
int cap;
int cost;
int rev;
};
struct PDijk{
int V;
int INF;
vector<int> pote, prevv, preve;
vector<vector<edge>> G;
PDijk(int N){
V =... |
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin... |
#include<bits/stdc++.h>
using namespace std;
template< typename flow_t, typename cost_t >
struct PrimalDual {
const cost_t INF;
struct edge {
int to;
flow_t cap;
cost_t cost;
int rev;
};
vector< vector< edge > > graph;
vector< cost_t > potential, min_cost;
vector< int > prevv, preve;
P... |
#line 1 "test/aoj/GRL_6_B.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_b"
#line 2 "test/aoj/../../graph/min-cost-flow.hpp"
#include <algorithm>
#include <vector>
#include <queue>
struct min_cost_flow {
struct edge { int to, cap, cost, rev; };
using P = std::pair<int, in... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin(... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<(n);++i)
const ll MOD=1e9+7;
template<typename T,typename E>
struct PrimalDual{
const E inf=numeric_limits<E>::max()/2;
struct edge{
int to,rev; T cap; E cost;
edge(int to,T cap,E cost,int rev):
... |
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 500
#define INF 1<<28
typedef pair<int,int> P;
struct edge{
int to,cap,cost,rev;
edge(){}
edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};
int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[M... |
#include <cstdio> // printf(), scanf()
#include <vector>
#include <algorithm> // min(), fill()
using namespace std;
static const int MAX_V = 100;
static const int INF = 100000000;
typedef struct edge_tbl
{
int to, cap, cost;
unsigned long rev;
} edge;
vector<edge> G[MAX_V];
int dist[MAX_V];
int pr... |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)
#define MAX_V 100
struct edge { int to, cap, cost,rev; };
int V; // ????... |
#include <algorithm>
#include <tuple>
#include <iostream>
#include <vector>
using namespace std;
#define MAX_V 200
#define INF 1000000
typedef tuple<int,int,int,int> Edge; // to,cap,cost,rev
int V;
typedef vector<Edge> Vertex;
vector<Vertex> G(MAX_V);
int dist[MAX_V];
int prev_v[MAX_V], prev_e[MAX_V];
void add_edge(... |
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;
struct Edge {
int to;
int cap;
int cost;
int rev;
};
vector<Edge> edges[101];
int primalDual(int s, int t, int f) {
int ret = 0;
priority_queue<pair<int, int>, vector<pair<in... |
#include <vector>
#include <queue>
#include <iostream>
using namespace std;
#define MAX_E 1001
int V, E, F, US[MAX_E], VS[MAX_E], CAP[MAX_E], COST[MAX_E];
class MinCostFlow {
public:
const int INFTY = (1 << 21);
struct Edge { int t, cap, cost, rev; };
struct P {
int d, id;
bool operator < (const P &othe... |
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX_V = 110;
static const int INF = (1<<30);
typedef pair<int, int> P;
struct edge{ int to, cap, cost, rev;};
int V;
vector<edge> G[MAX_V];
int h[MAX_V], dist[MAX_V], prevv[MAX_V], preve[MAX_V];
void ... |
#include <bits/stdc++.h>
using namespace std;
#if __has_include("print.hpp")
#include "print.hpp"
#endif
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a <... |
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
struct edge{
//行先、容量、コスト、逆辺
int to,cap,cost,rev;
};
void add_edge(int from,int to,int cap ,int cost,vector<vector<edge> > &g){
g[from].push_back( (edge) { to,cap,cost,(int)g[to].size() } );
g[to].push_back( (edge){from,0, -cost,(int)g[from].size()-1});
... |
#include <bits/stdc++.h>
using namespace std;
template<class T>
struct min_cost_flow {
using value_type = T;
using P = pair<value_type, int>;
private :
const value_type INF = numeric_limits<value_type>::max();
struct edge {
public :
int to, rev;
value_type cap;
value_type cost;
edge (int to, value_type... |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x... |
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
template <typename Flow, typename Cost> class PrimalDual {
private:
Cost INF_COST = std::numeric_limits<Cost>::max();
public:
struct Edge {
int to;
Flow cap;
Cost cost;
int rev;
Edge () {}
Edge (int t, Flow f, Cost c, in... |
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int MAX_V = 1e5 + 1;
const int INF = 1e9 + 1;
typedef pair< int, int > P;
// O(|E||V|^2)
struct Edge {
Edge(int _to, int _cap, int _cost, int _rev)
: to(_to), cap(_cap), cost(_cost), rev(_rev) {}
int to, cap, cost, rev; // 逆辺
};
in... |
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
template<class T> struct PrimalDual {
struct Edge {
int to, rev;
T cap, cost;
Edge () {}
Edge (int _to, T _cap, T _cost, int _rev) :
to(_to), cap(_cap), cost(_co... |
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef pair <int, int> pii;
const int INF = 0x3f3f3f3f;
int n, e, f, c[1005][1005];
vector <pii> adj[1005];
int dij(int s, int t, vector <int> &p, vector <int> &d) {
// cout << "WTFF" << endl;
... |
#include<iostream>
using namespace std;
//Minimum Cost Flow O(FE log V)
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<limits>
template<typename T>
struct MCF{
struct edge{
int to,rev,cap;
T cost;
};
vector<vector<edge> >G;
vector<T>h,d;
vector<int>pv,pe;
MCF(int n_=0):G(n_),h... |
#include <iostream>
#include <vector>
#include <numeric>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
template<typename Int = int>
struct PrimalDual {
struct Edge {
int dst;
Int cap;
Int flow;
Int cost;
int rev;
... |
#include <iostream>
using namespace std;
#include <utility>
#include <vector>
#include <queue>
typedef pair<int, int> P;
class MinCostFlow {
#define MAX_V 10001
private:
const int INF = 1e9 + 10;
struct Edge {
int to, cap, cost, rev;
Edge(int to, int cap, int cost, int rev):
to(to), cap(cap), cost(... |
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int inf=0xfffffff;
struct edge{
int to,cap,cost,rev;
};
int v;
vector<edge> G[105];
int dist[105],prevv[105],preve[105];
void add_edge(int from,int to,int cap,int cost){
G[from].push_back((edge){to,cap,cost,(int)G[to]... |
#include<bits/stdc++.h>
using namespace std;
#define mkp(x,y) (make_pair(x,y))
typedef pair<int,int> P;
class Edge
{
public:
int to,cap,cost,rev;
Edge(int a,int b,int c,int d)
{
to=a;cap=b;cost=c;rev=d;
}
};
class MCMF
{
public:
vector<vector<Edge> > G;
vector<int> dist;
vector<i... |
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct PrimalDual{
const int INF = 1<<28;
typedef pair<int,int> P;
struct edge{
int to,cap,cost,rev;
edge(){}
edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};
int n;
vector<vector<... |
#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_V 100
#define MAX_E 1000
using namespace std;
typedef pair<int, int> P;
struct edge {
int to, cap, cost, rev;
edge(int to_, int cap_, int cost_, int rev_)
: to(to_), cap(cap_), cost(cost_), rev(rev_) {}
};
int V, E;
vector<edge> G[MAX_V];
int h[MAX_V];
in... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<30;
typedef struct{
int to, cap, cost, rev;
}Edge;
class MinCostFlow{
private:
int V;
vector<vector<Edge>> G;
public:
MinCostFlow(int V): V(V){
G.resize(V);
}
void add_edge(int u, int v, int c, int d){
G[u].push_... |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60
#define MAX_V 10000
struct edge{
int to;
int cap;
int cost;
int rev;
edge(){}
edge(int to,int cap,int cost,int rev):to(to),cap(cap),co... |
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
const int MAX_V = 100010;
using Capacity = int;
using Cost = int;
const auto inf = numeric_limits<Capacity>::max() / 8;
struct Edge {
int dst;... |
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
namespace MCF{
const int MAXN=120;
const int MAXM=2100;
int to[MAXM];
int next[MAXM];
int first[MAXN];
int c[MAXM];
long long w[MAXM];
long long pot[MAXN];
int rev[MAXM];
long long ijk[MAXN];
int v[MAXN];
long lo... |
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=ve... |
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;
const int maxq=1005;
struct edge{int to,cap,cost,rev;};
int n,m,k;
int d[maxn];
int a[maxn];
int p1[maxn];
int p2[maxn];
bool inq[maxn];
vector<edge>G[maxn];
void add_edge(int u,int v,int c,int w) {
G[u]... |
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
template<typename CAP, typename COST>
class MinCostFlow {
public:
explicit MinCostFlow(int N) : g(N) {}
void addEdge(int src, int dst, CAP cap, COST cost){
int r1 = g[src].size();
int r2 = g[dst].size();
g[src]... |
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const i64 MOD = 1e9 + 7;
template <typename T, typename U>
struct PrimalDual{
struct Edge{
int to, rev;
U cap;
T cost;
Edge(int to, U cap, T cost, int rev) :
to(to), rev(rev), cap(cap), cost(cost){}
... |
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f... |
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int INF = 1e9;
struct Edge {
int from, to, cap, flow, cost;
Edge(int from, int to, int cap, int flow, int cost):from(from), to(to), cap(cap),
flow(flow), cost(cost){}
};
struct MaxflowMinCost {
int n;
vector<Ed... |
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 100000... |
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>... |
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(... |
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
struct min_cost_flow
{
struct edge{int to,cap,cost,rev;};
int V;
vector<vector<edge>> g;
public:
min_cost_flow(int n)
{
V=n;
g.resize(n,vector<edge>());
}
void add_edge(int from,int to,int cap ,int cost)
{
... |
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
#define MAX_V 201
#define INF 1000000000
typedef pair<int, int> P;
struct edge{int to, cap, cost, rev;};
int V;
vector<edge> G[MAX_V];
int h[MAX_V... |
#include <bits/stdc++.h>
using namespace std;
struct Primal_Dual
{
const int INF = 1 << 30;
typedef pair< int, int > Pi;
struct edge
{
int to, cap, cost, rev;
};
vector< vector< edge > > graph;
vector< int > potential, min_cost, prevv, preve;
Primal_Dual(int V) : graph(V) {}
void add_edge(int... |
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.