一定要仔细算内存,,,又少写一个零。。

 #include <bits/stdc++.h>

 using namespace std;

 template<const int _n,const int _m>
struct Edge
{
struct Edge_base { int to,next,w; }e[_m]; int cnt,p[_n];
void insert(const int x,const int y,const int z)
{ e[++cnt].to=y; e[cnt].next=p[x]; e[cnt].w=z; p[x]=cnt; }
void clear() { cnt=,memset(p,,sizeof(p)); }
Edge() { clear(); } int start(const int x) { return p[x]; }
Edge_base& operator[](const int x) { return e[x]; }
}; int n,m,Dis[];
bool visited[];
Edge<,>e; void Dijkstra(const int S)
{
int i,t,temp;
typedef pair<int,int> PII;
priority_queue<PII,vector<PII>,greater<PII> >Q;
memset(Dis,0x3f,sizeof(Dis));
Dis[S]=;
Q.push(make_pair(,S));
while(!Q.empty())
{
t=Q.top().second;Q.pop();
if(visited[t])continue;
visited[t]=true;
for(i=e.start(t);i;i=e[i].next)
{
temp=e[i].to;
if(Dis[temp]>Dis[t]+e[i].w)
{
Dis[temp]=Dis[t]+e[i].w;
Q.push(make_pair(Dis[temp],temp));
}
}
}
return ;
} int Get(const int x,const int y,const int z)
{
if(x< || y>=m)return (n-)*(m-)*+;
if(x>=n || y<)return ;
return ((x-)*(m-)+y)<<|z;
} int main()
{
int i,j,x; scanf("%d%d",&n,&m); for(i=;i<=n;++i)
{
for(j=;j<m;++j)
{
scanf("%d",&x);
e.insert(Get(i,j,),Get(i-,j,),x);
e.insert(Get(i-,j,),Get(i,j,),x);
}
} for(i=;i<n;++i)
{
for(j=;j<=m;++j)
{
scanf("%d",&x);
e.insert(Get(i,j-,),Get(i,j,),x);
e.insert(Get(i,j,),Get(i,j-,),x);
}
} for(i=;i<n;++i)
{
for(j=;j<m;++j)
{
scanf("%d",&x);
e.insert(Get(i,j,),Get(i,j,),x);
e.insert(Get(i,j,),Get(i,j,),x);
}
} Dijkstra(); printf("%d\n",Dis[(n-)*(m-)*+]); return ;
}

[bzoj1001]狼爪兔子[平面图的最小割等于其对偶图的最短路]的更多相关文章

  1. BZOJ 1001 狼抓兔子 平面图的最小割

    题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1001 题目大意: 见链接 思路: 求最小割,平面图的最小割等价于对偶图的最短路 直接建 ...

  2. BZOJ_1001_狼抓兔子_(平面图求最小割+对偶图求最短路)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1001 1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Sec   ...

  3. BZOJ 1001 狼抓兔子 (网络流最小割/平面图的对偶图的最短路)

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1001 算法讨论: 1.可以用最大流做,最大流等于最小割. 2.可以把这个图转化其对偶图,然 ...

  4. Luogu2046 NOI2010 海拔 平面图、最小割、最短路

    传送门 首先一个不知道怎么证的结论:任意点的\(H\)只会是\(0\)或\(1\) 那么可以发现原题的本质就是一个最小割,左上角为\(S\),右下角为\(T\),被割开的两个部分就是\(H=0\)与\ ...

  5. BZOJ1001 BeiJing2006 狼抓兔子 【网络流-最小割】*

    BZOJ1001 BeiJing2006 狼抓兔子 Description 现在小朋友们最喜欢的"喜羊羊与灰太狼",话说灰太狼抓羊不到,但抓兔子还是比较在行的,而且现在的兔子还比较 ...

  6. bzoj 1001 原图最小割转化为对偶图最短路

    题目大意: 现在小朋友们最喜欢的"喜羊羊与灰太狼",话说灰太狼抓羊不到,但抓兔子还是比较在行的, 而且现在的兔子还比较笨,它们只有两个窝,现在你做为狼王,面对下面这样一个网格的地形 ...

  7. 【bzoi2006】【狼抓兔子】【最小割】

    Description Source: Beijing2006 [BJOI2006] 八中OJ上本题链接:http://www.lydsy.com/JudgeOnline/problem.php?id ...

  8. 最小割&网络流应用

    重要链接 基础部分链接 : 二分图 & 网络流初步 zzz大佬博客链接 : 网络流学习笔记 重点内容:最小割二元关系新解(lyd's ppt) 题目:网络流相关题目 lyd神犇课件链接 : 网 ...

  9. 【bzoj1001】【最短路】【对偶图】【最大流转最小割】狼抓兔子题解

    [BZOJ1001]狼抓兔子 1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 18872  Solved ...

随机推荐

  1. [Swift通天遁地]一、超级工具-(9)在地图视图MKMapView中添加支持交互动作的标注图标

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  2. python实现对某招聘网接口测试获取平台信息

    """通过接口测试的技术获取某招聘网平台的资料"""url = "https://www.lagou.com/jobs/posit ...

  3. C#命名空间 using的用法

    using的用法: 1. using指令:引入命名空间 这是最常见的用法,例如: using System; using Namespace1.SubNameSpace; 2. using stati ...

  4. 思维题 URAL 1409 Two Gangsters

    题目传送门 /* 思维题:注意题目一句话:At some moment it happened so that they shot one and the same can. 如果两个人都有射中的话, ...

  5. O - Combinations (组合数学)

    Description Computing the exact number of ways that N things can be taken M at a time can be a great ...

  6. Spring抽象JDBC,使用JdbcTemplate

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  7. 【转】数据倾斜是多么痛?spark作业/面试/调优必备秘籍

    原博文出自于: http://sanwen.net/a/gqkotbo.html 感谢! 来源:数盟 调优概述 有的时候,我们可能会遇到大数据计算中一个最棘手的问题——数据倾斜,此时Spark作业的性 ...

  8. LN : leetcode 258 Add Digits

    lc 258 Add Digits lc 258 Add Digits Given a non-negative integer num, repeatedly add all its digits ...

  9. poj2367 Genealogical tree

    思路: 拓扑排序,这里是用染色的dfs实现的.在有环的情况下可以判断出来,没有环的情况下输出拓扑排序序列. 实现: #include <vector> #include <cstri ...

  10. 【译】x86程序员手册26-7.5任务切换

    7.5 Task Switching 任务切换 The 80386 switches execution to another task in any of four cases: 80386在以下四 ...