Bzoj 1001. Bjoi 2006 Wolf Catch Rabbit

Source: Internet
Author: User
Main Topic

Give an illustration, where 21 points are s and the other point is T. Ask the minimum cut. Thinking of solving problems

n∗m≤106 n*m≤10^6, this picture of the network flow can be over.
The map is obviously. However, the biggest doubt is why in the bidirectional side, the forward and reverse of the two edge of the same value.
First of all, why should the network flow build a reverse arc.
If the U u point in the diagram flows x x at the v Point, the reverse arc <v,u>=x =x is built, indicating that if there is a better scheme for the flow, v V can flow x x traffic back to u u.
The conservation of the flow: the whole map In addition to the Yuanhui point, how much traffic flow to this point, the point is how much flow out.
if U-v flow x x, v V to u u flow x x, u U is not flowing to V v.
In fact, the reverse arc is some, but carried out the following wave operation.
if u u to v V has two edges, then these two edges can be combined into one, capacity of the original two edges and.
Therefore the capacity of the U u to v V is combined with the edge of X x and the capacity of U-U to v V for the 0 0 edge, and the V V to U-u capacity for the edge of X x and V V to U-U is combined with a capacity of 0 0. So it seems that the positive and negative two sides of the same value. Code

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <
cmath> #define N 1010 #define INF 2147483647 #define FO (i,a,b) for (i=a;i<=b;i++) using namespace std; struct note{int to,next,val;};
Note Edge[n*n*6];
int tot,head[n*n];
int I,j,n,m,u,v,s,t,x,ans;
int pos[n][n];
int qu[n*6010],height[n*n];
    int read () {int Fh=1,rs=0;char ch; while (ch< ' 0 ' | |
    Ch> ' 9 ') && (ch^ '-')) Ch=getchar ();
    if (ch== '-') Fh=-1,ch=getchar ();
    while (ch>= ' 0 ' &&ch<= ' 9 ') rs= (rs<<3) + (rs<<1) + (ch^ ' 0 '), Ch=getchar ();
return fh*rs; } void lb (int x,int y,int z) {edge[++tot].to=y;edge[tot].next=head[x];edge[tot].val=z;head[x]=tot;} bool BFS () {m
    Emset (height,-1,sizeof (height));
    height[s]=0;
    int i,j,x,l,r;
    L=0,r=1;
    Qu[r]=s;
        while (L<r) {x=qu[++l]; for (I=head[x];i;i=edge[i].next) if (edge[i].val>0&&height[edge[i].to]==-1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.