#include<stdio.h>
#include<stdlib.h>
#include<math.h>
struct Location {
int x;
int y;
};
bool Visited[100];
int MaxDistance;
int N;
bool DFS(int Point, struct Location* L);
bool JudgeLive(Location a1);
bool JudgeJump(Location a1, Location a2);
bool JudgeCircle(Location a1);
int main()
{
scanf("%d %d", &N, &MaxDistance);
struct Location* L = (struct Location*)malloc(sizeof(struct Location) * N);
bool flag = false;
for (int i = 0; i < N; i++)
{
scanf("%d %d", &L[i].x, &L[i].y);
}
for (int i = 0; i < N; i++)
{
if (Visited[i] == false&&JudgeCircle(L[i]))
{
flag = DFS(i, L);
if (flag == true)
{
printf("Yes");
return 0;
}
}
}
printf("No");
}
bool JudgeJump(Location a1, Location a2)
{
return (pow(a1.x - a2.x, 2) + pow(a1.y - a2.y, 2) <= pow(MaxDistance, 2));
}
bool JudgeLive(Location a1)
{
return(abs(50 - a1.x) <= MaxDistance || abs(-50 - a1.x) <= MaxDistance || abs(50 - a1.y) <= MaxDistance || abs(-50 - a1.y) <= MaxDistance);
}
bool DFS(int Point, struct Location* L)
{
bool Judge=false;
Visited[Point] = true;
if (JudgeLive(L[Point]))
Judge = true;
else
{
for (int j =0;j < N; j++)
{
if (Visited[j]==false&&JudgeJump(L[Point], L[j]))
{
Judge = DFS(j, L);
if (Judge == true)
break;
}
}
}
return Judge;
}
bool JudgeCircle(Location a1)
{
return(pow(a1.x, 2) + pow(a1.y, 2) <= pow(MaxDistance + 7.5, 2));
}
就是把鳄鱼位置放在结构数组里
博客内容提及把鳄鱼位置存于结构数组,涉及信息技术中数据结构里数组的应用。
5553

被折叠的 条评论
为什么被折叠?



