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

时间限制
200 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue

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 (<=100), the number of crocodiles, and D, the maximum distance that James could jump. Then N lines follow, each containing the (x, y) 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

提交代码

 #include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
#include<string>
using namespace std;
struct point{
int x,y;
double dis;
bool vis;
point(){
vis=false;
}
};
double getdis(int x1,int y1,int x2,int y2){
int dx=x1-x2;
int dy=y1-y2;
return sqrt(dx*dx+dy*dy);
}
int abs(int a){
if(a<){
a=-a;
}
return a;
}
point cro[];
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int n,J;
int i;
queue<int> q;
scanf("%d %d",&n,&J);
point *cro=new point[n];
for(i=;i<n;i++){
scanf("%d %d",&cro[i].x,&cro[i].y);
cro[i].dis=getdis(,,cro[i].x,cro[i].y);
}
if(7.5+J>=){
printf("Yes\n");
return ;
}
for(i=;i<n;i++){
if(cro[i].dis<=7.5){
cro[i].vis=true;//无效点
}
else if(cro[i].dis<=7.5+J){//在弹跳范围内,收集
q.push(i);
cro[i].vis=true;
}
}
int curnum,x,y;
while(!q.empty()){
curnum=q.front();
q.pop();
x=cro[curnum].x;
y=cro[curnum].y;
if(abs(x)+J>=||abs(y)+J>=){//可以到达岸边
printf("Yes\n");
return ;
}
for(i=;i<n;i++){
if(!cro[i].vis){
cro[i].dis=getdis(x,y,cro[i].x,cro[i].y);
if(cro[i].dis<=J){
q.push(i);
cro[i].vis=true;
}
}
}
}
printf("No\n");
return ;
}

pat05-图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. 05-图2. Saving James Bond - Easy Version (25)

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

  4. Saving James Bond - Easy Version (MOOC)

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

  5. 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 ...

  6. PAT Saving James Bond - Easy Version

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

  7. 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 ...

  8. 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 ...

  9. 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. Oracle 函数-字符型函数

    1.字符型函数 函数 说明 案例 结果 ASCII(X) 求字符X的ASCII码 select ASCII('A') FROM DUAL; 65 CHR(X) 求ASCII码对应的字符 select ...

  2. SQLAlchemy外键的使用

    orm可以将数据库存储的数据封装成对象,同时,如果封装的好的话,所有的数据库操作都可以封装到对象中.这样的代码在组织结构上会非常的清晰,并且相对与使用sql语句在sql注入方面会极具降低. SQLAl ...

  3. UncategorizedSQLException Mybatis中jdbcType的作用

    使用MyBatis框架做更新操作时,在该字段需要更新的内容为空时,就会出现1111错误,也就是无效的列类型,这个时候你就要使用jdbcType.至于什么时候要使用到javaType我还没遇到过,而且我 ...

  4. P2891 [USACO07OPEN]吃饭Dining 最大流

    \(\color{#0066ff}{ 题目描述 }\) 有F种食物和D种饮料,每种食物或饮料只能供一头牛享用,且每头牛只享用一种食物和一种饮料.现在有n头牛,每头牛都有自己喜欢的食物种类列表和饮料种类 ...

  5. luogu1900 自我数

    分享一个非正解的做法 本题解内存最低(\(\le1\rm MiB\)) 但是不开O2会tle 思路:每个数字仅会更新出1个新的数字,而且这个新数字比旧数字最多也就大70多.所以这里还是利用" ...

  6. php屏蔽错误消息

    定义和用法: error_reporting() 设置 PHP 的报错级别并返回当前级别. 函数语法: error_reporting(report_level) 如果参数 level 未指定,当前报 ...

  7. linux1--常用命令

    1.目录结构 2./etc:系统配置文件存放地 比如你的wsgi的配置文件,nginx 3./usr 应用程序存放地 比如你的jdk应用程序存放地 4./root 系统管理员root的家目录 4.1像 ...

  8. springboot整合activemq(三)配置文件

    application.properties文件配置: #服务端口,8080被另一服务占用server.port=9090spring.activemq.broker-url=tcp://127.0. ...

  9. spring cloud 超时时间

    zuul.host.socket-timeout-millis=60000 #zuul socket连接超时zuul.host.connect-timeout-millis=60000 #zull 请 ...

  10. react 什么是虚拟DOM?深入了解虚拟DOM

    底层的理论基础 一. 原始生成步骤 1.state 数据 2.jsx 模版 3.数据 + 模板 结合,生成真实的DOM,来显示 4.state 发生改变了 5.数据 + 模板 结合,生成真实的DOM, ...