2018.10.22
简单重述一下,James Bond被困在直径15的湖心岛上,整个湖可以模拟成一个100*100的矩阵,湖上有可供跳跃的陆地点(其实是鳄鱼背),每次007有一个最大的跳跃半径maxdist,问007能否成功逃脱跳到岸上。
这道题实际上是一道图题,但是却并不需要用邻接表或邻接矩阵建立一个图,只需要记录下所有可供跳跃的结点,把跳跃路径作为边,再进行一个简单的DFS,判断能够到达只需要一个简单的勾股定理即可。BFS的原理可以回顾:#数据结构与算法学习笔记#PTA18:图(邻接表)+DFS(深度优先搜索)+BFS(广度优先搜索)(C/C++)。需要注意的地方是由于湖心岛有15的直径,和其他结点不同,所以第一跳需要区分讨论。
Saving James Bond - Easy Version
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 t