# Bzoj 2007 Altitude

Source: Internet
Author: User

http://www.lydsy.com/JudgeOnline/problem.php?id=2007

Ideas:

Obviously the elevation is a 0, another 1, the answer is 01 of the dividing line of traffic.

The figure in the subject is a plan, so the minimum cut can be converted to the shortest path of the dual graph, according to Gword said: There is a unified to the edge of the 90 ° clockwise, and also, to the first S and T edge, to "split" the outermost space, and then the S and t separate.

`1#include <algorithm>2#include <cstdio>3#include <cmath>4#include <cstring>5#include <iostream>6#include <queue>7 using namespacestd;8 intfirst[250005],next[2000005],go[2000005],tot,val[2000005];9 intdis[250005],vis[250005],s,t,n;Ten intRead () { One     CharCh=getchar ();intt=0, f=1; A      while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} -      while('0'<=ch&&ch<='9') {t=t*Ten+ch-'0'; ch=GetChar ();} -     returnt*F; the } - voidInsertintXintYintz) { -tot++; -go[tot]=y; +next[tot]=First[x]; -first[x]=tot; +val[tot]=Z; A } at voidAddintXintYintz) { - Insert (x, y, z); - } - intIdintXinty) { -     if(x==0|| y==n+1)returnT; -     if(x==n+1|| y==0)returnS; in     return(X-1) *n+y; - } to voidDijkstra () { +memset (DIS,127/3,sizeofdis); -priority_queue< pair<int,int>,vector< pair<int,int> >,greater<pair<int,int> > >Q; thedis[s]=0; *Q.push (Make_pair (0, S)); \$      while(!Q.empty ()) {Panax Notoginseng         intnow=Q.top (). Second; Q.pop (); -         if(Vis[now])Continue; thevis[now]=1; +          for(intI=first[now];i;i=Next[i]) { A             intPur=Go[i]; the             if(dis[pur]>dis[now]+Val[i]) { +dis[pur]=dis[now]+Val[i]; - Q.push (Make_pair (Dis[pur],pur)); \$             } \$         } -     } - } the intMain () { -n=read ();Wuyis=0, t=n*n+1; the      for(intI=1; i<=n+1; i++) -       for(intj=1; j<=n;j++) WuAdd (ID (I,J), id (i-1, J), read ()); -      for(intI=1; i<=n;i++) About       for(intj=1; j<=n+1; j + +) \$Add (ID (i,j-1), ID (i,j), read ());  -      for(intI=1; i<=n+1; i++) -       for(intj=1; j<=n;j++) -Add (ID (i-1, J), ID (i,j), read ());  A      for(intI=1; i<=n;i++) +       for(intj=1; j<=n+1; j + +) theAdd (ID (I,J), ID (i,j-1), read ()); - Dijkstra ();  \$printf"%d\n", Dis[t]); the}`

Bzoj 2007 Altitude

Related Keywords:

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.