• <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>
            posts - 74,  comments - 33,  trackbacks - 0
            ChiBi

            Time Limit: 5 Seconds      Memory Limit: 32768 KB

            watashi's mm is so pretty as well as smart. Recently, she has watched the movie Chibi. So she knows more about the War of ChiBi. In the war, Cao Cao had 800,000 soldiers, much more than his opponents'. But he was defeated. One of the mistakes he made was that he connected some of his boats together, and these boats were burned by the clever opponents.

            Then an interesting problem occurs to watashi's mm. She wants to use this problem to check whether watashi is as smart as her. However, watashi has no idea about the problem. So he turns to you for help.

            You know whether two boats are directly connected and the distance between them. And Fire's speed to spread between boats is 1m/s. You also know the time your soldiers need to travel from your camp to each boat. Because burning Cao Cao's boat is a very dangerous job, you must choose the least number of soldiers, and each one can only burn one boat. How much time do you need to burn all the Cao Cao's boats?

            Input

            The input contains several test cases. Each test case begins with a line contains only one integer 0 <= N <= 1000, which indicates the number of boats. The next N lines, each line contains N integers in range [0, 10000], the jth number in the ith line is the distance in metre between the ith boat and the jth boat, if the number is -1, then these two boats are not directly connected (d(i, j) == d(j, i) && d(i, i) == 0). Then N intergers in range [0, 10000], the ith number is the time in second your soldiers need to travel from the camp to the ith boat. What's more Cao Cao is not that stupid, so he won't connect more than 100 boats together.

            Output

            The shortest time you need to burn all the Cao Cao's boats counting from the soldiers leave the camp in a single line.

            Sample input

            4
            0 1 2 -1
            1 0 4 -1
            2 4 0 -1
            -1 -1 -1 0
            1 2 4 8
            

            Sample Output

            8
            該死的-1 我一直調(diào)試的代碼最后發(fā)現(xiàn)自己的-1居然沒處理
            暈死
            代碼如下
             1#include<stdio.h>
             2int map[1010][1010],flag[1010];
             3int time[1010];
             4int main()
             5{
             6    int n,i,j,k,sum,min;
             7    while(scanf("%d",&n)!=EOF)
             8    {
             9        for(i=0;i<n;i++)
            10        {
            11            for(j=0;j<n;j++)
            12                scanf("%d",&map[i][j]);
            13            flag[i]=0;
            14        }

            15        for(i=0;i<n;i++)
            16            scanf("%d",&time[i]);
            17        for(k=0;k<n;k++)
            18            for(i=0;i<n;i++)
            19                if(i!=k&&map[i][k]>=0)
            20                    for(j=0;j<n;j++)
            21                        if(j!=k&&map[k][j]>=0)
            22                        {
            23                            if(map[i][j]==-1)map[i][j]=map[i][k]+map[k][j];
            24                            else if(map[i][k]+map[k][j]<map[i][j])map[i][j]=map[i][k]+map[k][j];
            25                        }

            26        for(i=0;i<n;i++)
            27        {
            28            int max=0;
            29            for(j=0;j<n;j++)
            30                if(map[i][j]>max)max=map[i][j];
            31            time[i]+=max;    
            32        }

            33        sum=0;
            34        for(i=0;i<n;i++)
            35        {
            36            if(!flag[i])
            37            {
            38                flag[i]=1;
            39                min=time[i];
            40                for(j=0;j<n;j++)
            41                    if(map[i][j]>=0&&!flag[j])
            42                    {
            43                        flag[j]=1;
            44                        if(min>time[j])min=time[j];    
            45                    }

            46            }

            47            if(sum<min)sum=min;    
            48        }

            49        printf("%d\n",sum);            
            50    }
                
            51}

            52Floyd思路
            posted on 2008-12-27 14:42 KNIGHT 閱讀(147) 評論(0)  編輯 收藏 引用
            <2008年12月>
            30123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            国产精品成人久久久久久久| 久久无码人妻精品一区二区三区| 国产精品成人99久久久久91gav| 色欲综合久久中文字幕网| 欧美精品福利视频一区二区三区久久久精品 | 久久久SS麻豆欧美国产日韩| 老司机午夜网站国内精品久久久久久久久 | 久久久久久久综合日本| 久久夜色精品国产亚洲| 九九99精品久久久久久| 色综合久久天天综合| 99久久国产免费福利| 国产成人精品久久一区二区三区av| 99久久精品免费看国产一区二区三区| 精品久久久噜噜噜久久久| 精品久久久久久综合日本| 超级碰久久免费公开视频| 久久精品一区二区影院| 欧美激情精品久久久久久久| AV无码久久久久不卡蜜桃| 久久精品a亚洲国产v高清不卡| 久久99精品国产自在现线小黄鸭| 久久最新精品国产| 麻豆国内精品久久久久久| 亚洲va久久久噜噜噜久久男同| 久久99久久99精品免视看动漫| 日韩精品国产自在久久现线拍| 国产福利电影一区二区三区久久久久成人精品综合 | 久久精品无码一区二区日韩AV| 久久婷婷是五月综合色狠狠| 亚洲欧美久久久久9999| 久久精品国产亚洲αv忘忧草 | 人妻无码αv中文字幕久久 | 天天躁日日躁狠狠久久| 94久久国产乱子伦精品免费| 精品久久久久久无码不卡| 久久综合九色综合欧美狠狠| 久久精品国产第一区二区| 久久精品国产久精国产果冻传媒| 久久精品亚洲一区二区三区浴池| 精品久久久久久无码免费|