This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of drug dealers. He was sent to a small piece of land at the center of a lake filled with crocodiles. There he performed the most daring action to escape -- he jumped onto the head of the nearest crocodile! Before the animal realized what was happening, James jumped again onto the next big head... Finally he reached the bank before the last crocodile could bite him (actually the stunt man was caught by the big mouth and barely escaped with his extra thick boot).

Assume that the lake is a 100 by 100 square one. Assume that the center of the lake is at (0,0) and the northeast corner at (50,50). The central island is a disk centered at (0,0) with the diameter of 15. A number of crocodiles are in the lake at various positions. Given the coordinates of each crocodile and the distance that James could jump, you must tell him whether or not he can escape.

Input Specification:

Each input file contains one test case. Each case starts with a line containing two positive integers N (≤), the number of crocodiles, and D, the maximum distance that James could jump. Then N lines follow, each containing the ( location of a crocodile. Note that no two crocodiles are staying at the same position.

Output Specification:

For each test case, print in a line "Yes" if James can escape, or "No" if not.

Sample Input 1:

14 20
25 -15
-25 28
8 49
29 15
-35 -2
5 28
27 -29
-8 -28
-20 -35
-25 -20
-13 29
-30 15
-35 40
12 12

Sample Output 1:

Yes

Sample Input 2:

4 13
-12 12
12 12
-12 -12
12 -12

Sample Output 2:

No

我的答案,岛居然有15的直径T.T
 #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h> struct Crocodile {
int x;
int y;
int Visited;
};
typedef struct Crocodile *Point; int ReadPoint(Point P, int N);
void PrintPoint(Point P, int N);
double PointDistance(Point P1, Point P2);
int DFS(Point P, int N, double D, int stand);
int IsUp(Point P, int stand, double D); int ReadPoint(Point P, int N)
{
int i;
P[].x = ;
P[].y = ;
P[].Visited = ;
for(i=;i<N;i++) {
scanf("%d %d\n", &P[i].x, &P[i].y);
P[i].Visited = ;
}
return ;
} void PrintPoint(Point P, int N)
{
int i;
for(i=;i<N;i++) {
printf("P[%d] X:%d Y:%d\n", i, P[i].x, P[i].y);
}
printf("----------------------------\n");
} double PointDistance(Point P1, Point P2)
{
return sqrt(pow((P1->x - P2->x), ) + pow((P1->y - P2->y), ));
} int IsUp(Point P, int stand, double D)
{
int xlen = -abs(P[stand].x);
int ylen = -abs(P[stand].y);
if(stand == && (xlen<=(D+7.5)
|| ylen<=(D+7.5))) {
return ;
} else if(stand!= && (xlen<=D || ylen<=D)) {
return ;
}
return ; //Not
} int DFS(Point P, int N, double D, int stand)
{
int i, ret=, isup, island;
// printf("p[%d] X:%d Y:%d ", stand, P[stand].x, P[stand].y);
P[stand].Visited = ;
if(stand == ) island = ;
isup = IsUp(P, stand, D);
if(isup) {
// printf("stand %d\n", stand);
return ;
}
for(i=;i<N;i++) {
if(!P[i].Visited && (PointDistance(&P[i], &P[stand]) <= (D+island*7.5))) {
// printf("D:%lf\n", PointDistance(&P[i], &P[stand]));
ret = DFS(P, N, D, i);
if(ret) {
return ret;
}
}
}
return ret;
} int main()
{
int N;
double D;
Point P, S; S = (Point)malloc(sizeof(struct Crocodile));
S->x = ;
S->y = ; scanf("%d %lf\n", &N, &D);
N++; //N = N + 1;
P = (Point)malloc(sizeof(struct Crocodile)*N);
ReadPoint(P, N);
// PrintPoint(P, N);
if(DFS(P, N, D, ))
printf("Yes\n");
else
printf("No\n"); return ;
}

06-图2 Saving James Bond - Easy Version(25 分)的更多相关文章

  1. PTA 06-图2 Saving James Bond - Easy Version (25分)

    This time let us consider the situation in the movie "Live and Let Die" in which James Bon ...

  2. 06-图2 Saving James Bond - Easy Version (25 分)

    This time let us consider the situation in the movie "Live and Let Die" in which James Bon ...

  3. pat05-图2. Saving James Bond - Easy Version (25)

    05-图2. Saving James Bond - Easy Version (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作 ...

  4. 05-图2. Saving James Bond - Easy Version (25)

    1 边界和湖心小岛分别算一个节点.连接全部距离小于D的鳄鱼.时间复杂度O(N2) 2 推断每一个连通图的节点中是否包括边界和湖心小岛,是则Yes否则No 3 冗长混乱的函数參数 #include &l ...

  5. Saving James Bond - Easy Version (MOOC)

    06-图2 Saving James Bond - Easy Version (25 分) This time let us consider the situation in the movie & ...

  6. Saving James Bond - Easy Version 原创 2017年11月23日 13:07:33

    06-图2 Saving James Bond - Easy Version(25 分) This time let us consider the situation in the movie &q ...

  7. PAT Saving James Bond - Easy Version

    Saving James Bond - Easy Version This time let us consider the situation in the movie "Live and ...

  8. PTA 07-图5 Saving James Bond - Hard Version (30分)

    07-图5 Saving James Bond - Hard Version   (30分) This time let us consider the situation in the movie ...

  9. 06-图2 Saving James Bond - Easy Version

    题目来源:http://pta.patest.cn/pta/test/18/exam/4/question/625 This time let us consider the situation in ...

  10. 06-图2 Saving James Bond - Easy Version (25 分)

    This time let us consider the situation in the movie "Live and Let Die" in which James Bon ...

随机推荐

  1. 聊聊Dubbo - Dubbo可扩展机制实战

    1. Dubbo的扩展机制 在Dubbo的官网上,Dubbo描述自己是一个高性能的RPC框架.今天我想聊聊Dubbo的另一个很棒的特性, 就是它的可扩展性. 如同罗马不是一天建成的,任何系统都一定是从 ...

  2. JS中的setTimeout()函数

    1.setTimeout() 方法 setTimeout() 方法用于在指定的毫秒数后调用函数或执行表达式.返回一个 ID(数字),可以将这个ID传递给 clearTimeout() 来取消执行. s ...

  3. 2018-2019 ACM-ICPC Brazil Subregional Programming Contest F. Music Festival

    题目:https://codeforces.com/gym/101908/problem/F 题意:给你n个舞台,每个舞台有很多个节目,每个节目有个开始时间,结束时间,价值,每个舞台至少出演过一个节目 ...

  4. TCP/IP协议 和 如何实现 互联网上点对点的通信

    1.参考:https://www.cnblogs.com/onepixel/p/7092302.html   TCP/IP 协议采用4层结构,分别是应用层.传输层.网络层 和 链路层   http 属 ...

  5. 前端每日实战:19# 视频演示如何用纯 CSS 创作一种有削铁如泥感觉的菜单导航特效

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/XqYroe 可交互视频教程 此视频 ...

  6. shell 截取变量的字符串

    假设有变量 var=http://www.linuxidc.com/test.htm一 # 号截取,删除左边字符,保留右边字符.echo ${var#*//}其中 var 是变量名,# 号是运算符,* ...

  7. HEAD请求

    平时用的最多的无外乎POST GET 很少用的HEAD 这次HEAD请求使用场景:判断资源是否存在

  8. 小米手机_adb安装apk报错”Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]“

    问题: adb安装apk至小米手机时,安装失败,报错提示“Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]”,如下图 ...

  9. 2019.7.26 NOIP 模拟赛

    这次模拟赛真的,,卡常赛. The solution of T1: std是打表,,考场上sb想自己改进匈牙利然后wei了(好像匈牙利是错的. 大力剪枝搜索.代码不放了. 这是什么神仙D1T1,爆蛋T ...

  10. Android深度探索-卷1第一章心得体会

     本章介绍了安卓系统移植与驱动开发的概述,安卓的系统架构有四层:1 Linux内核,2 c/c++代码库, 3 Android SDK API, 4 应用程序 在读的过程中看到了专业名词,查了查,长点 ...