青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

poj1125

Stockbroker Grapevine

Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 18729 Accepted: 10120

Description

Stockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge in the stock market. For maximum effect, you have to spread the rumours in the fastest possible way.

Unfortunately for you, stockbrokers only trust information coming from their "Trusted sources" This means you have to take into account the structure of their contacts when starting a rumour. It takes a certain amount of time for a specific stockbroker to pass the rumour on to each of his colleagues. Your task will be to write a program that tells you which stockbroker to choose as your starting point for the rumour, as well as the time it will take for the rumour to spread throughout the stockbroker community. This duration is measured as the time needed for the last person to receive the information.

Input

Your program will input data for different sets of stockbrokers. Each set starts with a line with the number of stockbrokers. Following this is a line for each stockbroker which contains the number of people who they have contact with, who these people are, and the time taken for them to pass the message to each person. The format of each stockbroker line is as follows: The line starts with the number of contacts (n), followed by n pairs of integers, one pair for each contact. Each pair lists first a number referring to the contact (e.g. a '1' means person number one in the set), followed by the time in minutes taken to pass a message to that person. There are no special punctuation symbols or spacing rules.

Each person is numbered 1 through to the number of stockbrokers. The time taken to pass the message on will be between 1 and 10 minutes (inclusive), and the number of contacts will range between 0 and one less than the number of stockbrokers. The number of stockbrokers will range from 1 to 100. The input is terminated by a set of stockbrokers containing 0 (zero) people.

Output

For each set of data, your program must output a single line containing the person who results in the fastest message transmission, and how long before the last person will receive any given message after you give it to this person, measured in integer minutes.
It is possible that your program will receive a network of connections that excludes some persons, i.e. some people may be unreachable. If your program detects such a broken network, simply output the message "disjoint". Note that the time taken to pass the message from person A to person B is not necessarily the same as the time taken to pass it from B to A, if such transmission is possible at all.

Sample Input

3
2 2 4 3 5
2 1 2 3 6
2 1 2 2 2
5
3 4 4 2 8 5 3
1 5 8
4 1 6 4 10 2 7 5 2
0
2 2 5 1 5
0

Sample Output

3 2
3 10
構圖,求出從一個頂點到其余頂點最遠的距離,然后求每個頂點這樣做之后的最小值,即為最小時間
顯然求多源最短路,題目中給出的數據范圍是1-100,floyd正合適,O(N^3)
寫好之后交了兩邊之后都wa,不明白
后來自習看了半天,發現找完最短路f[][]時候,查找答案過程中是在map[][]中找的,壞習慣害死人啊,
這里說一下,其實只用一個數組記錄圖就行,在起基礎上操作即可
這次的樣例夠陰險的,找完最短路后矩陣居然沒變……
 1#include<stdio.h>
 2#include<string.h>
 3#include<math.h>
 4#define MAX 100
 5#define M 210000000
 6int point,ans;
 7int n,map[MAX+5][MAX+5],f[MAX+5][MAX+5];
 8void init()
 9{
10    int i,j,t;
11    int a,b;
12    for (i=0; i<=n ; i++ )
13        for (j=0; j<=n ; j++ )
14        {
15            map[i][j]=M;
16        }

17    for (i=1; i<=n ; i++ )
18    {
19        scanf("%d",&t);
20        for (j=1; j<=t; j++)
21        {
22            scanf("%d%d",&a,&b);
23            map[i][a]=b;
24        }

25    }

26
27    for (i=1; i<=n ; i++ )
28        for (j=1; j<=n ; j++ )
29            f[i][j]=map[i][j];
30}

31int work()
32{
33    int min;
34    int i,j,k;
35    for (k=1; k<=n ; k++ )
36        for (i=1; i<=n ; i++ )
37            for (j=1; j<=n ; j++ )
38                if ((i!=j)&&(j!=k)&&(k!=i))
39                    if (f[i][j]>f[i][k]+f[k][j])
40                    {
41                        f[i][j]=f[i][k]+f[k][j];
42                    }

43    ans=M;
44    for (i=1; i<=n ; i++ )
45    {
46        min=0;
47        for (j=1; j<=n ; j++ )
48            if (f[i][j]>min&&i!=j)
49            {
50                min=f[i][j];
51            }

52        if (min<M)
53        {
54            if (min<ans)
55            {
56                point=i;
57                ans=min;
58            }

59        }

60    }

61}

62int main()
63{
64    int flag;
65    int i;
66    while (scanf("%d",&n)!=EOF&&n!=0)
67    {
68        init();
69        work();
70        if (ans>M)
71            printf("disjoint\n");
72        else
73            printf("%d %d\n",point,ans);
74    }

75    return 0;
76}

77

posted on 2012-02-07 23:31 jh818012 閱讀(251) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

導航

統計

常用鏈接

留言簿

文章檔案(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
  • 評論內容較長,點擊標題查看
  • --王私江
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产精品久久毛片a| 黑人一区二区三区四区五区| 欧美日韩精品久久久| 国产亚洲观看| 午夜精品福利视频| 亚洲美女精品一区| 欧美freesex交免费视频| 狠狠色丁香婷婷综合久久片| 欧美一级欧美一级在线播放| 一本色道久久综合亚洲精品按摩| 欧美国产国产综合| 亚洲精品久久久一区二区三区| 麻豆久久婷婷| 久久精品免费播放| 红桃视频国产精品| 久久一区激情| 久久亚裔精品欧美| 亚洲激情在线播放| 亚洲黄色成人久久久| 欧美大尺度在线| 亚洲激情六月丁香| 亚洲三级观看| 欧美性猛交xxxx乱大交蜜桃 | 国产欧美日韩精品丝袜高跟鞋| 亚洲免费一在线| 亚洲一级一区| 国产在线精品一区二区中文| 久久躁日日躁aaaaxxxx| 老司机精品视频网站| 亚洲精品自在久久| 这里只有视频精品| 国内精品视频在线播放| 欧美激情亚洲激情| 欧美日韩中文| 久久米奇亚洲| 欧美刺激午夜性久久久久久久| 亚洲天堂网在线观看| 午夜欧美精品| 亚洲精品国产精品久久清纯直播 | 老牛嫩草一区二区三区日本| 亚洲欧洲日产国产综合网| 亚洲六月丁香色婷婷综合久久| 欧美天天综合网| 久久精品人人做人人爽电影蜜月| 久久久久久久久久久久久久一区| 亚洲精选在线观看| 亚洲一级二级在线| 激情自拍一区| 亚洲美女区一区| 国产主播精品| 日韩视频在线你懂得| 国产在线日韩| 日韩视频免费| 精久久久久久| 亚洲作爱视频| 亚洲电影免费在线观看| 宅男66日本亚洲欧美视频| 亚洲性感激情| 亚洲人线精品午夜| 欧美一级日韩一级| 99视频精品免费观看| 久久精品国产亚洲一区二区| 亚洲视频图片小说| 久久日韩粉嫩一区二区三区| 亚洲免费婷婷| 欧美国产日韩精品免费观看| 久久久免费av| 国产精品卡一卡二卡三| 亚洲激情黄色| 在线看不卡av| 欧美中文字幕精品| 亚洲男女自偷自拍图片另类| 欧美成人午夜免费视在线看片| 久久精品视频在线免费观看| 欧美性猛交xxxx免费看久久久| 亚洲第一色中文字幕| 国产一在线精品一区在线观看| 9久re热视频在线精品| 亚洲日本aⅴ片在线观看香蕉| 久久精品官网| 久久久久国产成人精品亚洲午夜| 欧美日韩日日骚| 亚洲精品乱码久久久久久蜜桃91| 伊人狠狠色j香婷婷综合| 欧美一区二区三区精品电影| 午夜精品国产更新| 欧美午夜一区二区| 99成人在线| 在线综合亚洲| 欧美午夜大胆人体| 一本大道av伊人久久综合| 99精品国产热久久91蜜凸| 欧美高清hd18日本| 最新国产乱人伦偷精品免费网站| 91久久综合亚洲鲁鲁五月天| 老牛嫩草一区二区三区日本| 久热re这里精品视频在线6| 伊人久久久大香线蕉综合直播| 香蕉久久a毛片| 久久精品最新地址| 狠狠v欧美v日韩v亚洲ⅴ| 久久久精品网| 欧美韩日精品| 一本一本a久久| 欧美色欧美亚洲高清在线视频| 亚洲美女黄网| 欧美一级专区免费大片| 国产精品一区二区久久国产| 亚洲制服丝袜在线| 久久国产精品一区二区三区| 精品99视频| 欧美va亚洲va香蕉在线| 最近中文字幕日韩精品 | 欧美日韩国产精品一卡| 日韩视频久久| 欧美在线观看一区二区| 国内精品久久久久久久影视麻豆| 久久久久一区| 亚洲美女视频在线观看| 香蕉成人久久| …久久精品99久久香蕉国产 | 国产精品久久久久久久久免费樱桃 | 免费成人性网站| 亚洲福利一区| 欧美片第一页| 亚洲欧美国产一区二区三区| 每日更新成人在线视频| 99视频精品免费观看| 国产精品尤物| 免费久久99精品国产自| 一本色道久久综合精品竹菊| 久久久久久亚洲精品不卡4k岛国| 一区免费在线| 国产精品v日韩精品v欧美精品网站| 欧美伊人久久| 亚洲看片网站| 久久综合色一综合色88| 亚洲性av在线| 亚洲国产精品一区| 国产欧美日韩精品专区| 欧美极品影院| 久久精品一区中文字幕| 一区二区三区免费看| 欧美激情精品久久久久久黑人| 亚洲欧美视频在线观看视频| 亚洲国产91| 国产偷久久久精品专区| 欧美日韩国产精品自在自线| 久久久久久国产精品mv| 国产精品99久久久久久宅男 | 欧美日韩免费| 久热精品视频在线观看| 亚洲在线视频免费观看| 亚洲国产欧美日韩另类综合| 久久国产一区二区三区| 宅男在线国产精品| 亚洲国产婷婷香蕉久久久久久99| 国产精品亚洲视频| 欧美日韩综合另类| 欧美精品不卡| 欧美88av| 蜜臀久久99精品久久久久久9 | 99精品视频免费观看| 国产一区二区三区免费观看| 国产精品成av人在线视午夜片| 欧美gay视频激情| 久久婷婷亚洲| 性伦欧美刺激片在线观看| 日韩亚洲视频| 亚洲人成网站777色婷婷| 欧美刺激午夜性久久久久久久| 久久蜜桃av一区精品变态类天堂| 午夜精品视频在线观看一区二区| 99综合视频| 91久久精品国产| 激情综合色丁香一区二区| 国产亚洲欧洲997久久综合| 国产欧美精品日韩精品| 国产精品永久免费| 国产精品一级| 国产日韩精品一区二区| 国产日韩欧美精品在线| 国产日韩一区在线| 国产亚洲欧美在线| 国产中文一区二区| 在线播放日韩专区| 亚洲高清免费| 亚洲欧洲在线播放| 日韩一区二区电影网| 欧美日韩一区二区精品| 欧美日韩精品免费| 国产精品yjizz| 国产精品自拍小视频| 国内成人在线| 亚洲国产激情| 日韩一级免费| 午夜精品电影| 乱中年女人伦av一区二区| 欧美激情按摩| 日韩视频免费观看|