Language: C++

#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rrep(i,n) for(ll i=(n)-1;i>=0;--i)
#define rep1(i,n) for(ll i=1;i<=(n);++i)
#define rrep1(i,n) for(ll i=(n);i>=1;--i)
#define fr first
#define sc second
#define pb push_back
#define INF 0xfffffff
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
struct edge{ll to,cap,rev; }; // ????????????????????????

vector<edge> G[100];
vector<edge> rG[100];
ll d[100];
ll a[100];
ll cnt=0;
void add_edge(ll from,ll to,ll cap){
	G[from].pb((edge){to, cap, rG[to].size() });
	rG[to].pb((edge){from, 0, G[from].size()-1} );
}

ll calc(ll t){
	ll res = 0;
	rep(i,rG[t].size()){
		res+=rG[t][i].cap;
	}
	return res;
}

ll max_flow(ll V,ll E,ll s,ll t){
	ll res=0;
	memset( d, 0, sizeof(d) );
	memset( a, 0, sizeof(a) );
	d[s] = V;
	a[s]=-1;
	a[t]=-1;
	rep(i,G[s].size()){
		if(e.to!=t){
			edge &e = G[s][i];
			a[e.to] += e.cap;
			rG[e.to][e.rev].cap = e.cap;
			e.cap = 0;
		}
		else{
			res+=G[s][i].cap;
		}
	}

	for(;;){
		ll v = -1;  //1
		rep(i,V){
			if( a[i]>0 ){
				v = i;
				break;
			}
		}
		if(v < 0) return res+calc(t);
		ll J=0; //2
		ll id;
		rep(i,G[v].size()){
			if( G[v][i].cap>0 && d[v] - d[G[v][i].to] == 1 ){
				id = i;
				J=1;
				break;
			}
		}
		if(!J) rep(i,rG[v].size()){
			if( rG[v][i].cap>0 && d[v] - d[rG[v][i].to] == 1 ){
				id = i;
				J=2;
				break;
			}
		}
	
		if(J){  //3
			edge &e = (J==1?G[v][id]:rG[v][id]);
			if(J==1){
				ll f = min(a[v], e.cap );
				a[v] -= f;
				e.cap -= f;
				rG[e.to][e.rev].cap += f;
				if(a[e.to]>=0) a[e.to] += f;
			}
			else{
				edge &efor = G[e.to][e.rev];
				ll f = min(a[v], e.cap);
				a[v] -= f;
				e.cap -= f;
				efor.cap += f;
				if(a[e.to]>=0) a[e.to] += f;
			}
		}

		else{  //4
			ll dmin=0xfffffff;
			rep(i,G[v].size()){
				if(G[v][i].cap>0) dmin = min(dmin,d[G[v][i].to]);
			}
			rep(i,rG[v].size()){
				if(rG[v][i].cap>0) dmin = min(dmin,d[rG[v][i].to]);
			}
			d[v] = dmin + 1;
		}
	}
}

ll V,E,A[1000],B[1000],C[1000];

void input(){
	scanf("%lld%lld",&V,&E);
	rep(i,E){
		scanf("%lld%lld%lld",&A[i],&B[i],&C[i]);
	}
}

int main()
{
	input();
	rep(i,V){
		G[i].clear(); rG[i].clear();
	}
	rep(i,E) add_edge(A[i], B[i], C[i]);
	cout<<max_flow(V,E,0,V-1)<<endl;
}

Compiler output:
a.cc: In function 'void add_edge(ll, ll, ll)':
a.cc:24:47: warning: narrowing conversion of 'rG[to].std::vector<edge>::size()' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'll' {aka 'long long int'} [-Wnarrowing]
   24 |         G[from].pb((edge){to, cap, rG[to].size() });
      |                                    ~~~~~~~~~~~^~
a.cc:25:49: warning: narrowing conversion of '(G[from].std::vector<edge>::size() - 1)' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'll' {aka 'long long int'} [-Wnarrowing]
   25 |         rG[to].pb((edge){from, 0, G[from].size()-1} );
      |                                   ~~~~~~~~~~~~~~^~
a.cc: In function 'll max_flow(ll, ll, ll, ll)':
a.cc:44:20: error: 'e' was not declared in this scope
   44 |                 if(e.to!=t){
      |                    ^
a.cc:45:31: error: redeclaration of 'edge& e'
   45 |                         edge &e = G[s][i];
      |                               ^
a.cc:44:20: note: '<typeprefixerror>e' previously declared here
   44 |                 if(e.to!=t){
      |                    ^