网络流结束后在残留网络上,从源点和汇点分别dfs,标记能够到达的点。
假如某边为关键边,那么:
1.该边残留流量为0
2.S可以到u,且v可以到T。
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n,m,S,T,tot,k;
int head[N];
struct node{
int u,nxt,cap,to,id;
}edge[int(2e5+100)];
int cur[N],deep[N];
void ae(int u,int v,int w){ //前向星加边
tot++;
edge[tot].u = u;
edge[tot].nxt = head[u];
edge[tot].to = v;
edge[tot].cap = w;
head[u] = tot;
}
bool bfs(){ //构建分层图
memset(deep,-1,sizeof(deep)); //-1表示未访问
queue<int>q;
q.push(S);
deep[S] = 0;
while(!q.empty()){
int u = q.front();
for(int i = head[u]; ~i;i = edge[i].nxt){
int v = edge[i].to;
if(deep[v]==-1&&edge[i].cap>0){