博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 1376 Animal Run 最短路
阅读量:7236 次
发布时间:2019-06-29

本文共 1978 字,大约阅读时间需要 6 分钟。

平面图最小割转最短路

书上是说以边为结点建图

但是我觉得好像以每块空白区域为结点建图会更自然点。把矩形的右上方编号为0,左下方编号为1,分别为起点终点

//#pragma comment(linker, "/STACK:1024000000,1024000000")#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair
pii;#define pb(a) push(a)#define INF 0x1f1f1f1f#define lson idx<<1,l,mid#define rson idx<<1|1,mid+1,r#define PI 3.1415926535898template
T min(const T& a,const T& b,const T& c) { return min(min(a,b),min(a,c));}template
T max(const T& a,const T& b,const T& c) { return max(max(a,b),max(a,c));}void debug() {#ifdef ONLINE_JUDGE#else freopen("in.txt","r",stdin); //freopen("d:\\out1.txt","w",stdout);#endif}int getch() { int ch; while((ch=getchar())!=EOF) { if(ch!=' '&&ch!='\n')return ch; } return EOF;}struct HeapNode{ int d,u; bool operator < (const HeapNode &ant) const { return d>ant.d; }};struct Edge{ int from,to; int dist;};const int maxn=2000005;struct Dijksta{ int n; vector
g[maxn]; vector
edge; int done[maxn]; int d[maxn]; void init(int n) { this->n=n; for(int i=0;i<=n;i++) g[i].clear(); edge.clear(); } void add(int u,int v,int w) { Edge e=(Edge){u,v,w}; edge.push_back(e); g[u].push_back(edge.size()-1); } void solve(int s) { for(int i=0;i<=n;i++) d[i]=INF; memset(done,0,sizeof(done)); d[s]=0; priority_queue
q; q.push((HeapNode){ 0,s}); while(!q.empty()) { HeapNode x=q.top();q.pop(); if(done[x.u])continue; int u=x.u; done[u]=1; for(int i=0;i
=m)return 0; if(a>=n||b<1)return 1; int &x=id[a][b][d]; if(x==0)x=++vcnt; return x;}int main(){ //freopen("d:\\in1.txt","r",stdin); int ca=0; while(scanf("%d%d",&n,&m)!=EOF&&m) { solver.init(n*m*2+2); vcnt=2; memset(id,0,sizeof(id)); //horizontal for(int i=1;i<=n;i++) for(int j=1;j
View Code

 

 

转载于:https://www.cnblogs.com/BMan/p/3632975.html

你可能感兴趣的文章
twitter bootstrap的html编码规范
查看>>
[翻译完成] 树莓派LCD显示器适配器
查看>>
比较underfined和null
查看>>
passwd被误清的奇遇遭遇
查看>>
FACL和Linux终端
查看>>
搭建全功能电子邮件服务器(lamp+postfix+extmail+extman)
查看>>
Delphi 的绘图功能[7] - PolyBezier、PolyBezierTo
查看>>
李娜,后海宁时代的代表
查看>>
分享一个自己写的JFinal的BaseController (1)
查看>>
linux启动过程故障解决
查看>>
【Java每日一题】20161230
查看>>
DHCP协议工作原理
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
Hive使用ORC格式存储离线表
查看>>
Spring工作原理
查看>>
httpd(2.2&2.4)RPM搭建配置定义详解
查看>>
ubuntu下字体
查看>>
linux压缩格式及安装包管理,screen
查看>>
我的友情链接
查看>>