//Dinic struct Edge{ int from,to,cap,flow; Edge(){ } Edge(int a,int b,int c,int d){ from=a; to=b; cap=c; flow=d; } }edges[maxm*]; int n,m,s,t,sz; vector<int> ve[maxn]; int dis[maxn],cur[maxn]; bool vis[maxn]; int l,r; void addEdge(int a,int b,int c)…