给出数字N(1<=N<=10000),X(1<=x<=1000),Y(1<=Y<=1000),代表有N个敌人分布一个X行Y列的矩阵上,矩形的行号从0到X-1,列号从0到Y-1再给出四个数字x1,y1,x2,y2,代表你要从点(x1,y1)移到(x2,y2)。在移动的过程中你当然希望离敌人的距离的最小值最大化,现在请求出这个值最大可以为多少,以及在这个前提下,你最少要走多少步才可以回到目标点。注意这里距离的定义为两点的曼哈顿距离,即某两个点的坐标分为(a,b),(c,d),那么它们的距离为|a-c|+|b-d|。

输入:

第一行给出数字N,X,Y

第二行给出x1,y1,x2,y2

下面将有N行,给出N个敌人所在的坐标

输出:

在一行内输出你离敌人的距离及在这个距离的限制下,你回到目标点最少要移动多少步。

Sample input

2 5 6

0 0 4 0

2 1

2 3

Sample output

2 14

/*
同bzoj热身赛,二维前缀和,灌水留坑
*/
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
const int maxn = ,inf = ;
inline int read(){
char ch=getchar();
int f=,x=;
while(!(ch>=''&&ch<='')){if(ch=='-')f=-;ch=getchar();};
while(ch>=''&&ch<=''){x=x*+(ch-'');ch=getchar();};
return x*f;
}
struct nd{
int x;
int y;
};
int p,n,m;
int ex[maxn],ey[maxn],xa,xb,ya,yb;
int flag,dis[][],vis[][];
short d[][],s[][];
int dx[] = {,,-,};
int dy[] = {,,,-};
bool emy[][];
inline bool jud(int x,int y,int t){
if(x < || y < || x >= m || y >= n) return false;
if(t == ) return true;
t--;
int tx=+x-y+t,ty=x+y+t,dx=+x-y-t,dy=x+y-t;
if(ty>=n+m-) ty = n+m-;
if(tx>=+m) tx = +m;
int tot = s[ty][tx];
if(dy>&&dx>-n) tot += s[dy-][dx-];
if(dy>) tot -= s[dy-][tx];
if(dx>-n) tot -= s[ty][dx-];
if(tot) return false;
else return true;
}
bool check(int t){
if(!jud(xa,ya,t)) return false;
flag++;
for(int i = ;i <= n+;i++){
for(int j = ;j <= m+;j++){
dis[i][j] = inf;
}
}
nd now,nxt;
now.x = xa;
now.y = ya;
queue<nd> q;
q.push(now);
dis[ya][xa] = ;
vis[ya][xa] = flag;
while(!q.empty()){
now = q.front();
q.pop();
//cout<<now.y<<" "<<now.x<<endl;
for(int dr = ;dr < ;dr++){
nxt.x = now.x + dx[dr];
nxt.y = now.y + dy[dr];
if(jud(nxt.x,nxt.y,t)&&vis[nxt.y][nxt.x] != flag){
dis[nxt.y][nxt.x] = dis[now.y][now.x] + ;
vis[nxt.y][nxt.x] = flag;
q.push(nxt);
if(nxt.y == yb && nxt.x == xb) return true;
}
}
}
return false;
}
int main(){
freopen("escape.in","r",stdin);
freopen("escape.out","w",stdout);
cin>>p>>m>>n>>xa>>ya>>xb>>yb;
for(int i = ;i <= p;i++){
scanf("%d%d",&ex[i],&ey[i]);
emy[ex[i]+ey[i]][+ex[i]-ey[i]] = true;
}
for(int i = ;i < n + m - ;i++){
for(int j = -n;j < +m;j++){
if(emy[i][j]) d[i][j] = d[i][j-] + ;
else d[i][j] = d[i][j-];
}
}
for(int i = ;i < n + m - ;i++){
for(int j = -n;j < +m;j++){
if(!i) s[i][j] = d[i][j];
else s[i][j] = s[i-][j] + d[i][j];
}
}
int l = ,r = n + m,mid,ans1,ans2;
while(l <= r){
mid = (l + r) >> ;
if(check(mid)){
ans1 = mid;
ans2 = dis[yb][xb];
l = mid + ;
}else{
r = mid - ;
}
}
cout<<ans1<<" "<<ans2;
return ;
}

黄学长模拟day1 大逃亡的更多相关文章

  1. 黄学长模拟day1 某种密码

    关于某种密码有如下描述:某种密码的原文A是由N个数字组成,而密文B是一个长度为N的01数串,原文和密文的关联在于一个钥匙码KEY.若KEY=∑▒[Ai*Bi],则密文就是原文的一组合法密码. 现在有原 ...

  2. 黄学长模拟day1 球的序列

    N个编号为1-n的球,每个球都有唯一的编号.这些球被排成两种序列,分别为A.B序列,现在需要重新寻找一个球的序列l,对于这个子序列l中任意的两个球,要求j,k(j<k),都要求满足lj在A中位置 ...

  3. HDOJ 1429 胜利大逃亡(续)

    胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  4. 胜利大逃亡(续)hdu1429(bfs)

    胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total S ...

  5. hdu1429胜利大逃亡(bfs)

    胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  6. hdu.1429.胜利大逃亡(续)(bfs + 0101011110)

    胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total S ...

  7. 胜利大逃亡[HDU1253]

    胜利大逃亡 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  8. hdu 1429 胜利大逃亡(续)

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1429 胜利大逃亡(续) Description Ignatius再次被魔王抓走了(搞不懂他咋这么讨魔王 ...

  9. Hdu 1429 胜利大逃亡(续) 分类: Brush Mode 2014-08-07 17:01 92人阅读 评论(0) 收藏

    胜利大逃亡(续) Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Subm ...

随机推荐

  1. [NOIP2014] 提高组 洛谷P1328 生活大爆炸版石头剪刀布

    题目描述 石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一样,则不分胜负.在<生活大爆炸>第二季第8 集中出现了一种石头剪刀布的升级版游戏. 升级版游戏在传统的 ...

  2. struts2 CVE-2014-0050(DoS), CVE-2014-0094(ClassLoader manipulation) S2-20 DoS attacks and ClassLoader manipulation

    catalog . Description . Effected Scope . Exploit Analysis . Principle Of Vulnerability . Patch Fix 1 ...

  3. 开个帖,开始学习shell编程

    恩,就这么开始了 首先说一下这个小小的插曲...写着写着,它就崩溃了,然后我也崩溃了...崩溃的我到处找一个不会让我崩溃的工具,然后找来找去就找到了scribefire. 1. 关于从Command ...

  4. HDU 2058 The sum problem

    传送门 Description Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequen ...

  5. iOS 简单的动画自定义方法(旋转、移动、闪烁等)

    #define kDegreesToRadian(x) (M_PI * (x) / 180.0) #define kRadianToDegrees(radian) (radian*180.0)/(M_ ...

  6. 关于adb连接手机offline的问题解决

    win7-64位系统.对于windows系统,adb devices 显示offline一般可能有两个原因: 1 )端口被占用. 解决方式是:查找端口号,结束占用进程: adb nodaemon se ...

  7. HDU5672String(尺标法)

    问题描述 有一个 10\leq10≤长度\leq 1,000,000≤1,000,000 的字符串,仅由小写字母构成.求有多少个子串,包含有至少k(1 \leq k \leq 26)k(1≤k≤26) ...

  8. POJ1050To the Max(求最大子矩阵)

    题目链接 题意:给出N*N的矩阵,求一个子矩阵使得子矩阵中元素和最大 分析: 必备知识:求一组数的最大连续和 int a[N]; ,maxn = -INF; ; i <= n; i++) { i ...

  9. 如何用iframe标签以及Javascript制作时钟?

    如何利用iframe标签以及Javascript制作时钟? 如何制作一个时钟呢?效果如下图所示: 这里的时钟会不停的走,但是下面的页面是不会变得,这样就实现了我们想要的效果了.下面我将分为以下几个方面 ...

  10. BZOJ2124: 等差子序列

    题意:给一个 1 到 N 的排列{Ai},询问是否存在 1<=p1<p2<p3<p4<p5<…<pLen<=N(Len>=3),使得 Ap1,Ap ...