• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            poj2253

            Frogger

            Time Limit: 1000MS Memory Limit: 65536K
            Total Submissions: 15072 Accepted: 4991

            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
            
             
            我一直是按照找到的一個指導ACMer的ACM練習做題目的,這個題目是在最短路中給出的
            確實沒想到怎么按照最短路來做
            找了下題解:最小生成樹的概念就是,連接各點的權值是所有樹中最小的
            所以找使得路徑中最長的一跳最短的過程就是構造最小生成樹的過程
            prim的做法,先把1點加入集合中,然后找距離集合最近的點,加入這條邊,并記錄
            直到2點加入集合中,停止構造。
            顯然當前生成樹中最長的一條邊就是所求的邊
             
            我以前的prim的寫法跟這個題目不合適,只好找了個題解,重寫的prim
             1#include<stdio.h>
             2#include<string.h>
             3#include<math.h>
             4#define MAX 250
             5#define e 0.0000001
             6double dis[MAX][MAX];
             7double x[MAX],y[MAX];
             8int bian[MAX][2],b1;
             9int v[MAX];
            10short vis[MAX];
            11int n;
            12double ans;
            13void init()
            14{
            15    int i,j;
            16    for (i=1; i<=n; i++) scanf("%lf%lf",&x[i],&y[i]);
            17    for (i=1; i<=n ; i++ )
            18        for (j=1; j<=n ; j++ )
            19            if (i!=j)
            20            {
            21                dis[i][j]=sqrt(fabs(x[i]-x[j])*fabs(x[i]-x[j])+fabs(y[i]-y[j])*fabs(y[i]-y[j]));
            22                dis[j][i]=dis[i][j];
            23            }

            24}

            25void prim()
            26{
            27    double dmin;
            28    int i,j,k;
            29    vis[1]=1;
            30    v[1]=1;
            31    for (i=2; i<=n; i++) vis[i]=0;
            32    for (i=1; i<=n ; i++ )
            33    {
            34        dmin=210000000;
            35        for (k=1; k<=i ; k++ )
            36            for (j=1; j<=n ; j++ )
            37                if ((vis[j]==0)&&(j!=v[k])&&(dis[v[k]][j]-e<dmin))
            38                {
            39                    dmin=dis[v[k]][j];
            40                    v[i+1]=j;
            41                    bian[i][0]=v[k];
            42                    bian[i][1]=j;
            43                }

            44        if (v[i+1]==2break;
            45        vis[v[i+1]]=1;
            46    }

            47    b1=i;
            48    dmin=0;
            49    for (i=1; i<=b1 ; i++ )
            50    {
            51        if (dis[bian[i][0]][bian[i][1]]-e>dmin)
            52        {
            53            dmin=dis[bian[i][0]][bian[i][1]];
            54        }

            55    }

            56    ans=dmin;
            57}

            58int main()
            59{
            60    int t;
            61    t=0;
            62    scanf("%d",&n);
            63    while (n!=0)
            64    {
            65        init();
            66        prim();
            67        t++;
            68        printf("Scenario #%d\n",t);
            69        printf("Frog Distance = %.3lf\n\n",ans);
            70        scanf("%d",&n);
            71    }

            72    return 0;
            73}

            74

            posted on 2012-02-13 21:15 jh818012 閱讀(393) 評論(0)  編輯 收藏 引用

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當于是 取余3的意思 因為 3 的 二進制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內容較長,點擊標題查看
            • --王私江
            久久午夜综合久久| 很黄很污的网站久久mimi色| 国产精品免费久久久久影院| Xx性欧美肥妇精品久久久久久| 国产精品久久久久久搜索| 久久青青草原国产精品免费| 国产午夜精品理论片久久| 一级女性全黄久久生活片免费 | 久久精品国产精品亚洲精品| 久久精品亚洲欧美日韩久久| 久久99国产精品久久| 亚洲综合婷婷久久| 91精品国产9l久久久久| 国产综合久久久久| 久久精品成人| 无码精品久久久久久人妻中字| 无码人妻久久一区二区三区免费| 国产∨亚洲V天堂无码久久久| 亚洲伊人久久大香线蕉苏妲己| 无码任你躁久久久久久久| 久久久久无码精品国产| 久久精品国产精品亜洲毛片| 日本强好片久久久久久AAA| 久久精品无码一区二区app| 无码精品久久久久久人妻中字| 国产精品免费久久久久久久久 | 色噜噜狠狠先锋影音久久| 亚洲欧美成人久久综合中文网 | 久久精品国产亚洲Aⅴ香蕉| 久久精品国产精品亚洲精品 | 美女久久久久久| 国产午夜精品久久久久免费视 | 狠狠色丁香婷综合久久| 99久久香蕉国产线看观香| 91精品国产91热久久久久福利 | 综合久久久久久中文字幕亚洲国产国产综合一区首 | 亚洲欧美成人综合久久久 | 狠狠综合久久AV一区二区三区| 国产99久久久国产精品~~牛| 久久综合噜噜激激的五月天| 久久人妻无码中文字幕|