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. HTTP请求流程基础知识

    HTTP协议解析: HTTP即超文本传输协议,是一种详细规定了浏览器和万维网服务器之间互相通信的规则,它是万维网交换信息的基础,它允许将HTML文档从WEB服务器传输到WEB浏览器. URL(统一资源 ...

  2. visual studio code的使用

    1.添加代码片段 参考:https://blog.csdn.net/qq_36370731/article/details/83014439 2.在vscode上运行Git 先打开vscode内置的G ...

  3. Rainbow的信号 CH3801

    题目链接 题意:求n个整数任意取一个区间,一起进行xor,and,或or的操作,求xor的期望值,and的期望值,or的期望值. 思路:区间取的左端点为l,右端点为r,当r==l时,选的概率为1/n/ ...

  4. 【Java架构:持续交付】一篇文章搞掂:Jenkins

    一.安装 1.使用yum本地安装 1.1.使用yum安装JDK a.检查系统是否有安装open-jdk rpm -qa |grep java rpm -qa |grep jdk rpm -qa |gr ...

  5. MySQL复制表结构和内容到另一个表中

    一:(低版本的mysql不支持,mysql4.0.25 不支持,mysql5已经支持了)1.复制表结构到新表CREATE TABLE 新表LIKE 旧表 2.复制旧表的数据到新表(假设两个表结构一样) ...

  6. 用倍增法构造后缀数组中的SA及RANK数组

    感觉后缀数组很难学的说= = 不过总算是啃下来了 首先 我们需要理解一下倍增法构造的原理 设原串的长度为n 对于每个子串 我们将它用'\0'补成长度为2^k的串(2^k-1<n<=2^k) ...

  7. C#进阶系列——WebApi 路由机制剖析:你准备好了吗? 转载https://www.cnblogs.com/landeanfen/p/5501490.html

    阅读目录 一.MVC和WebApi路由机制比较 1.MVC里面的路由 2.WebApi里面的路由 二.WebApi路由基础 1.默认路由 2.自定义路由 3.路由原理 三.WebApi路由过程 1.根 ...

  8. 箫声远(本人)的小站(为展示作品、简历,基于github pages)

    箫声远的个人前端小站在线地址

  9. 洛谷P4169 [Violet]天使玩偶/SJY摆棋子(CDQ分治)

    [Violet]天使玩偶/SJY摆棋子 题目传送门 解题思路 用CDQ分治开了氧气跑过. 将输入给的顺序作为第一维的时间,x为第二维,y为第三维.对于距离一个询问(ax,ay),将询问分为四块,左上, ...

  10. PAT_A1074#Reversing Linked List

    Source: PAT A1074 Reversing Linked List (25 分) Description: Given a constant K and a singly linked l ...