poj-2253-Frogger ゝ一世哀愁。 2022-05-28 12:07 113阅读 0赞 Frogger <table> <tbody> <tr> <td><strong>Time Limit:</strong> 1000MS</td> <td> </td> <td><strong>Memory Limit:</strong> 65536K</td> </tr> <tr> <td><strong>Total Submissions:</strong>54307</td> <td> </td> <td><strong>Accepted:</strong> 17140</td> </tr> </tbody> </table> Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimming and instead reach her by jumping. Unfortunately Fiona's stone is out of his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach her by a sequence of several small jumps. To execute a given sequence of jumps, a frog's jump range obviously must be at least as long as the longest jump occuring in the sequence. The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones. You are given the coordinates of Freddy's stone, Fiona's stone and all other stones in the lake. Your job is to compute the frog distance between Freddy's and Fiona's stone. Input The input will contain one or more test cases. The first line of each test case will contain the number of stones n (2<=n<=200). The next n lines each contain two integers xi,yi (0 <= xi,yi <= 1000) representing the coordinates of stone \#i. Stone \#1 is Freddy's stone, stone \#2 is Fiona's stone, the other n-2 stones are unoccupied. There's a blank line following each test case. Input is terminated by a value of zero (0) for n. Output For each test case, print a line saying "Scenario \#x" and a line saying "Frog Distance = y" where x is replaced by the test case number (they are numbered from 1) and y is replaced by the appropriate real number, printed to three decimals. Put a blank line after each test case, even after the last one. Sample Input 2 0 0 3 4 3 17 4 19 4 18 5 0 Sample Output Scenario #1 Frog Distance = 5.000 Scenario #2 Frog Distance = 1.414 Source [Ulm Local 1997][] 题目大意:给出青蛙的坐标,以及各个石块的坐标,求1号青蛙到2号青蛙之间至少需要跳的最大距离,不是最短路问题,路可以很长,跳的石头很多,要求是跳的最大距离,最小; 代码: #include<queue> #include<math.h> #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> using namespace std; #define inf 99999999 double e[1010][1010]; int book[1010]; double dis[1010]; struct point { int x,y; double z; } a[10000]; double di(point A,point B) { return sqrt((double)((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y))); } int main() { int n,q=1; while(scanf("%d",&n)!=EOF) { int i,j,k,u,v,w; double minn; if(n==0) break; for(i=1; i<=n; i++) { for(j=1; j<=n; j++) { if(i==j) e[i][j]=0; else e[i][j]=inf; } } for(i=1; i<=n; i++) { scanf("%d%d",&a[i].x,&a[i].y); } for(i=1; i<=n; i++) { for(j=i+1; j<=n; j++) { double d=di(a[i],a[j]); e[i][j]=e[j][i]=d; } } for(i=1; i<=n; i++) dis[i]=e[1][i]; for(i=1; i<=n; i++) book[i]=0; book[1]=1; for(i=1; i<=n-1; i++) { minn=inf; for(j=1; j<=n; j++) { if(book[j]==0&&dis[j]<minn) { minn=dis[j]; u=j; } } book[u]=1; for(v=1; v<=n; v++) { dis[v]=min(dis[v],max(dis[u],e[u][v])); } } printf("Scenario #%d\n",q++); printf("Frog Distance = %.3lf\n\n",dis[2]); } return 0; } [Ulm Local 1997]: http://poj.org/searchproblem?field=source&key=Ulm+Local+1997
相关 最短路径?青蛙(Frogger), ZOJ1942, POJ2253 感觉只是用了最短路径的思想啊。 bellman算法是神奇的迭代,dijkstra是神奇的贪心。 看了下面这个图,感到这特么就是个最小生成树的计算过程啊。 ![Center 朴灿烈づ我的快乐病毒、/ 2024年02月17日 23:47/ 0 赞/ 30 阅读
相关 B - Frogger POJ - 2253————最短路变形 [题目链接->][-] 题意是:一个青蛙 到另一个青蛙的最短距离就是 最小必要跳跃的距离。 其实这个题是单元最短路题变形体, 但是我为了简单 用了floyed, 这个时 素颜马尾好姑娘i/ 2023年08月17日 16:31/ 0 赞/ 100 阅读
相关 [kuangbin带你飞]专题四 最短路练习 B( POJ 2253) Frogger(spfa) B - Frogger(spfa) 题目链接:[https://vjudge.net/contest/66569\problem/B][https_vjudge.net_ - 日理万妓/ 2023年08月17日 15:40/ 0 赞/ 105 阅读
相关 POJ 2253-Frogger(最小生成树-给定终点) Frogger <table> <tbody> <tr> <td><strong>Time Limit:</strong> 1000MS</td> 柔情只为你懂/ 2022年07月11日 12:25/ 0 赞/ 119 阅读
相关 B - Frogger——spfa() Think: 1知识点:spfa()算法求最短路 2题意:n = 1 的青蛙要跳到 n = 2 的青蛙哪里,可以其它石头作为中介,询问在可达路径中青蛙至少要能跳多远 心已赠人/ 2022年06月12日 05:11/ 0 赞/ 144 阅读
相关 POJ 2253 Frogger floyd变形 滴,集训第二十五天打卡。 最近又好热好热了呀... POJ 2253 Frogger Freddy Frog is sitting on a stone in the m 曾经终败给现在/ 2022年06月10日 05:55/ 0 赞/ 145 阅读
相关 poj 2253(区间DP) [原题][Link 1] 思路:求所有路径中最大跳跃距离的最小值, 很诡异的是输出答案如果用G++,.3lf%格式会出错,c++可以过 include<cstdio 男娘i/ 2022年06月04日 03:05/ 0 赞/ 216 阅读
相关 poj-2253-Frogger Frogger <table> <tbody> <tr> <td><strong>Time Limit:</strong> 1000MS</td> ゝ一世哀愁。/ 2022年05月28日 12:07/ 0 赞/ 114 阅读
相关 POJ - 2253 Frogger(迪杰斯特拉变形) Frogger Description Freddy Frog is 素颜马尾好姑娘i/ 2022年05月19日 14:29/ 0 赞/ 128 阅读
还没有评论,来说两句吧...