#include #include using namespace std; const int maxn = 100; // agar tewdad yal ha km bashad ta 300 niz javab midahad int n, m, s, t, excess[maxn], flow[maxn][maxn], capacity[maxn][maxn], h[maxn]; vector G[maxn]; void push(int u, int v){ int amount = min(excess[u] , capacity[u][v]-flow[u][v]); excess[u] -= amount; excess[v] += amount; flow[u][v] += amount; flow[v][u] -= amount; } void relabel(int u){ int newheight = 2*n-1; for(int v=0; v 0) newheight = min(newheight, h[v]+1); } h[u] = newheight; } int main(){ cin >> n >> m >> s >> t; s--, t--; for(int i=0; i> u >> v >> cap; u--, v--; G[u].push_back(v); G[v].push_back(u); capacity[u][v] = cap; } for(int i=0; i 0){ next = true; for(int i=0; i h[v]) push(u,v) ; // agar available nabashad hichi push nemishavad } if(excess[u] > 0) relabel(u); // agar excess hanooz mosbat bood digar pushi nadarim } } cntinue = next; } cout << excess[t] << endl; // dar in ja excess[t] andaze shar bishine ast zira hich gah t ra push nemikonim return 0; }