Language: C++


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 4;

struct edge {
	int to;
	int cap;
	int rev;
	edge(int _to, int _cap, int _rev) : to(_to), cap(_cap), rev(_rev) {};
};

int par[N], pare[N], possibleflow[N];
using node = vector<edge>;
using graph = vector<node>;


int aug(graph &g, int s, int t, int f) {
	memset(par, -1, sizeof(par));
	par[s] = s;
	possibleflow[s] = INT_MAX;
	deque<int> q;
	q.push_back(s);
	while (!q.empty()) {
		auto i = q.front();
		q.pop_front();
		for (auto &e : g[i]) {
			if (e.cap > 0 && par[e.to] == -1) {
				par[e.to] = i;
				pare[e.to] = e.rev;
				possibleflow[e.to] = min(possibleflow[i], e.cap);
				if (e.to == t) {
					auto df = possibleflow[t];
					while (par[t] != t) {
						g[t][pare[t]].cap += df;
						g[par[t]][g[t][pare[t]].rev].cap -= df;
						t = par[t];
					}
					return df;
				}
				q.push_back(e.to);
			}
		}
	}
	return 0;
}

int maximum_flow(graph &g, int s, int t) {
	int df;
	int flow = 0;
	do {
		df = aug(g, s, t, INT_MAX);
		flow += df;
	} while (df != 0);
	return flow;
}

void addedge(graph &g, int from, int to, int cap) {
	g[from].PB(edge(to, cap, g[to].size()));
	g[to].PB(edge(from, 0, g[from].size() - 1));
}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A
int main() {
	int v, e;
	scanf("%d%d", &v, &e);
	graph g(v);
	REP(i, e) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		addedge(g, x, y, z);
	}
	cout << maximum_flow(g, 0, v - 1) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int aug(graph&, int, int, int)':
a.cc:85:27: error: 'INT_MAX' was not declared in this scope
   85 |         possibleflow[s] = INT_MAX;
      |                           ^~~~~~~
a.cc:28:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   27 | #include <cstdint>
  +++ |+#include <climits>
   28 | #include <tuple>
a.cc: In function 'int maximum_flow(graph&, int, int)':
a.cc:116:35: error: 'INT_MAX' was not declared in this scope
  116 |                 df = aug(g, s, t, INT_MAX);
      |                                   ^~~~~~~
a.cc:116:35: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'