POJ 2253 Frogger floyd变形 曾经终败给现在 2022-06-10 05:55 160阅读 0赞 滴,集训第二十五天打卡。 最近又好热好热了呀... **POJ 2253 Frogger** 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 **题目大意:给定n个点的坐标,青蛙要从点1跳到点2,求最短路。** #include <iostream> #include <string.h> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; struct point { double x,y; }pp[210]; double map[210][210],dis[210][210]; int main() { int count=0,i,j,k,n; while(scanf("%d",&n),n) { for(i=1;i<=n;++i) scanf("%lf%lf",&pp[i].x,&pp[i].y); for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { map[i][j]=sqrt((pp[j].x-pp[i].x)*(pp[j].x-pp[i].x)+(pp[j].y-pp[i].y)*(pp[j].y-pp[i].y)); dis[i][j]=map[i][j]; } } printf("Scenario #%d\nFrog Distance = ",++count); for(k=1;k<=n;k++) { for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(dis[i][j]>max(dis[i][k],dis[k][j])) dis[i][j]=max(dis[i][k],dis[k][j]); } } } printf("%.3lf\n\n",dis[1][2]); } return 0; }
相关 最短路径?青蛙(Frogger), ZOJ1942, POJ2253 感觉只是用了最短路径的思想啊。 bellman算法是神奇的迭代,dijkstra是神奇的贪心。 看了下面这个图,感到这特么就是个最小生成树的计算过程啊。 ![Center 朴灿烈づ我的快乐病毒、/ 2024年02月17日 23:47/ 0 赞/ 49 阅读
相关 B - Frogger POJ - 2253————最短路变形 [题目链接->][-] 题意是:一个青蛙 到另一个青蛙的最短距离就是 最小必要跳跃的距离。 其实这个题是单元最短路题变形体, 但是我为了简单 用了floyed, 这个时 素颜马尾好姑娘i/ 2023年08月17日 16:31/ 0 赞/ 112 阅读
相关 [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 赞/ 124 阅读
相关 POJ 2253-Frogger(最小生成树-给定终点) Frogger <table> <tbody> <tr> <td><strong>Time Limit:</strong> 1000MS</td> 柔情只为你懂/ 2022年07月11日 12:25/ 0 赞/ 135 阅读
相关 POJ2253 Frogger(Floyd) 题目描述:青蛙A要找青蛙B,路径任选,求所有可能路径中跳的最远的一步,它们之中的最小距离值。 输入要求,第一行为石头数,二三行为起点和终点位置,n-2行为其他石头结点。第一 ╰半橙微兮°/ 2022年07月11日 06:56/ 0 赞/ 119 阅读
相关 POJ 2253 Frogger floyd变形 滴,集训第二十五天打卡。 最近又好热好热了呀... POJ 2253 Frogger Freddy Frog is sitting on a stone in the m 曾经终败给现在/ 2022年06月10日 05:55/ 0 赞/ 161 阅读
相关 poj 2253(区间DP) [原题][Link 1] 思路:求所有路径中最大跳跃距离的最小值, 很诡异的是输出答案如果用G++,.3lf%格式会出错,c++可以过 include<cstdio 男娘i/ 2022年06月04日 03:05/ 0 赞/ 233 阅读
相关 poj-2253-Frogger Frogger <table> <tbody> <tr> <td><strong>Time Limit:</strong> 1000MS</td> ゝ一世哀愁。/ 2022年05月28日 12:07/ 0 赞/ 130 阅读
相关 POJ - 2253 Frogger(迪杰斯特拉变形) Frogger Description Freddy Frog is 素颜马尾好姑娘i/ 2022年05月19日 14:29/ 0 赞/ 146 阅读
还没有评论,来说两句吧...