Test instructions: has given to the graph, given the starting point and end point s,t, ask how many points in the diagram can be removed to make s T unreachable
Ideas:
According to the conventional idea is to find a shortest, the most short-circuiting all points not meet the conditions, and then in the quickest way to engage in a good
In order to deepen the understanding of the minimum cut, I wrote the question with the smallest cut.
A split, a 1 edge between the split, with the edge of the edge of the INF, the maximum flow, it is clear that the key point of the split between the flow is full stream and must be the smallest cut.
And then from the full stream + minimum cut these two points can be spicy, if U-V is not the smallest cut, then the residual network s must be up to V, so on the residual network BFSS point.
/* **********************************************auther:kalilicreated TIME:2015/6/17 18:10:30File name:hdu_3313_ Key_vertex minimum cut. cpp*********************************************** *///accepted 3313 2386MS 19136K 5692 B C + + #pragma Comment (linker, "/stack:1024000000,1024000000") #include <iostream> #include <cstring> #include <cmath > #include <queue> #include <stack> #include <list> #include <map> #include <set># Include <sstream> #include <string> #include <vector> #include <cstdio> #include <ctime># Include <bitset> #include <algorithm> #define SZ (x) ((int) (x). Size ()) #define ALL (v) (v). Begin (), (v). End () # Define foreach (I, v) for (__typeof ((v). Begin ()) I = (v). Begin (); I! = (v). End (); + + i) #define REP (i,n) for (int i=1; i< ; =int (n); i++) using namespace Std;const int inf = 0x3f3f3f3f;const int N = 200000 +100;const int M = 300000*10+10;struct edge{ int v,w,nxt; Edge () {} edge (int v,int W,int nxt): V (v), W (W), NXT (NXT) {}}es[m];int n,m;int head[n];int cnt;void inline add_edge (int u,int v,int W) {es[cnt] =edge (V,w,head[u]); head[u]=cnt++; Es[cnt]=edge (U,0,head[v]); head[v]=cnt++;} int s,g;int h[n],q[n],tail;bool makeh (int s,int g) {memset (h,0,sizeof (h)); H[s]=1; tail=0; Q[tail++]=s; for (int i=0;i<tail;i++) {int u = q[i]; if (U = = g) return true; for (int i = Head[u];~i;i = es[i].nxt) {int v = es[i].v,w = ES[I].W; if (w&&h[v] = = 0) Q[tail++]=v,h[v] = h[u]+1; }} return false;} int dfs (int u,int g,int maxf) {if (U = = g) return MAXF; int ans=0; for (int i = Head[u];~i;i = es[i].nxt) {int v = es[i].v,w = ES[I].W; if (w&&h[v] = = h[u]+1) {int f = DFS (V,g,min (Maxf-ans, W)); Ans + = f; ES[I].W-= f; ES[I^1].W + = f; if (ans = = MAXF) return ans; }} if (ans = = 0) h[u]=-1; return ans;} int dinic (int s,int g) {int ans=0; while (Makeh (s,g)) Ans+=dfs (S,g,inf); return ans;} BOOL Vis[n];int que[n],top;void BFS (int src) {que[top++] = src; Vis[src]=1; for (int i = 0;i < top; i++) {int u=que[i]; for (int i = head[u]; ~i; i = es[i].nxt) {int v = es[i].v,w = ES[I].W; if (w&&vis[v] = = 0) que[top++]=v,vis[v]=1; }}}void Ini () {cnt=0; memset (head,-1,sizeof (Head));} int main () {while (~scanf ("%d%d", &n,&m)) {ini (); REP (i,m) {int u,v; scanf ("%d%d",&U,&V); Add_edge (U+n,v,inf); } scanf ("%d%d", &s,&g); for (int i=0;i<n;i++) {if (i==s| | i==g) Add_edge (i,i+n,2); else Add_edge (i,i+n,1); } int Ans=dinic (s,g+n); if (ans = = 2) puts ("2"); if (ans = = 0) printf ("%d\n", N); if (ans = = 1) {int cnt=0; int src=s; ES[HEAD[S]].W = es[head[g]].w=0; memset (vis,0,sizeof (VIS)); while (true) {top=0; BFS (SRC); BOOL flag=0; for (int i =0; i < top; i++) {int u=que[i]; if (flag) break; for (int i = Head[u];~i;i = es[i].nxt) { if (i&1) continue; int V=ES[I].V,W=ES[I].W; if (w = = 0 && vis[v] = = 0) { cnt++; src = v; flag=1; Break }}} if (Src==g+n) BR Eak } printf ("%d\n", CNT); } }}
Hdu_3313_key_vertex (min cut)