1339/1163: [Baltic2008]mafia

Source: Internet
Author: User

1163: [Baltic2008]mafia time limit:10 Sec Memory limit:162 MB
submit:96 solved:60
[Submit] [Status] [Discuss] Description Bandits prepare to transfer drugs from one station to another station, the police are ready to carry out the have been supervised. There is a price to be have been supervised for each station, and now the police want to use the minimum cost to control some stations, so that after the removal of these stations, the bandits can not reach the target point from the original initial point of input n,m represents the total number of stations, and how many two-way side to connect them. 2<=n<=200, 1 <=m<=20000. The second line gives two numbers, a, a, a, and a target point for the culprit. 1<=a,b<=n,a<>b. Then there are N rows, giving the money needed to have been supervised the first station, not more than 10 000 000 down the M line, to describe the structure of the diagram. Minimum number of moneysample Input required for output5 6
5 3
2
4
8
3
10
1 5
1 2
2 4
4 5
2 3
3 4Sample Output5HINT Source

Problem: A ha-ha of the smallest cut, each topic in the station split into two points, and then connected to a side right for the cost of the side of the site, and then other topics described in the side directly connected to the two-way side, pay attention to don't mess it just

1/**************************************************************2Problem:11633 User:hansbug4 language:pascal5 result:accepted6Time:156Ms7Memory:2652KB8****************************************************************/9  Ten type OnePoint=^node; ANode=Record - G,w:longint; - Next,anti:point; the     End; - var - I,j,k,l,m,n,s,t,ans:longint; -A:Array[0.. the] ofPoint ; +D,DV:Array[0.. the] ofLongint; - functionmin (x,y:longint): Longint; +          begin A               ifX<y ThenMin:=xElsemin:=y; at          End; - procedureAdd (x,y,z:longint); -           varP:point; -           begin -New (p);p ^.g:=y;p^.w:=z;p^.next:=a[x];a[x]:=p; -New (p);p ^.g:=x;p^.w:=0;p ^.next:=a[y];a[y]:=p; ina[x]^.anti:=a[y];a[y]^.anti:=A[x]; -           End; to functionDFS (x,flow:longint): Longint; +          varP:point;k:longint; -          begin the               ifX=t Thenexit (flow); *dfs:=0;p: =A[x]; $                whileP<>Nil  DoPanax Notoginseng                     begin -                          if(p^.w<>0) and(D[x]= (d[p^.g]+1)) Then the                             begin +K:=dfs (P^.g,min (flow-dfs,p^.w)); A                                  ifP^.w<>maxlongint ThenDec (p^.w,k); the                                  ifP^.anti^.w<>maxlongint ThenInc (P^.ANTI^.W,K); +Inc (DFS,K);ifDfs=flow Thenexit; -                             End; $p:=P^.next; $                     End; -               ifD[s]=n Thenexit; - Dec (dv[d[x]]); the               ifdv[d[x]]=0  Thend[s]:=N; - Inc (D[x]); Inc (Dv[d[x]);Wuyi          End; the begin - readln (n,m); Wu       fori:=1  toN2  Doa[i]:=Nil; -READLN (s,t); s:=s*2-1; t:=t*2; About       fori:=1  toN Do $          begin - Readln (j); -Add (i*2-1, i*2, j); -          End; A       fori:=1  toM Do +          begin the readln (j,k); -Add (j*2, k*2-1, maxlongint); $Add (k*2, j*2-1, maxlongint); the          End; theFillchar (Dv,sizeof (DV),0); theFillchar (d,sizeof (d),0); theans:=0; n:=n*2; -       whileD[s]<n DoInc (Ans,dfs (S,maxlongint)); in writeln (ans); the Readln; the End.

1339/1163: [Baltic2008]mafia

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.