当前位置: 代码迷 >> 综合 >> 06-图2 Saving James Bond - Easy Version(25 分)
  详细解决方案

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

热度:59   发布时间:2023-12-25 04:32:51.0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
int E,N,flag;
int visit[200]={
   0};
struct crocodile
{int x;int y;
}croco[200];
int reachFromCenter(crocodile p){
   //中间岛屿需要额外判断return (15+E)*(15+E)>=p.x*p.x+p.y*p.y;
}
int success(crocodile a){
   //判断跳出的点是否在岸上return a.x>=50-E||a.y>=50-E||a.x-E<=-50||a.y-E<=-50;
}
int move(crocodile a,crocodile b){
   //鳄鱼头上跳return E*E>=(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
void DFS(int n){
   //深度优先搜索if(success(croco[n])){flag=1;}else{for(int i=0;i<N;i++){if(!visit[i]&&move(croco[n],croco[i])){visit[i]=1;DFS(i);}}}return;
}
int main(){cin>>N>>E;if(E>=35){flag=1;}else{for(int i=0;i<N;i++){cin>>croco[i].x>>croco[i].y;}for(int i=0;i<N;i++){if(!visit[i]&&reachFromCenter(croco[i])){
   //跳出小岛到鳄鱼身上visit[i]=1;DFS(i);}}}if(flag) printf("Yes\n");else printf("No\n");return 0;
}
  相关解决方案