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

ACM PKU 1125 Stockbroker Grapevine 圖論 Floyd算法

http://acm.pku.edu.cn/JudgeOnline/problem?id=1125 

Stockbroker Grapevine 

Time Limit:1000MS  Memory Limit:10000K 
Total Submit:2602 Accepted:1503 
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 
32 2 4 3 52 1 2 3 62 1 2 2 253 4 4 2 8 5 31 5 84 1 6 4 10 2 7 5 202 2 5 1 50 


Sample Output 
3 23 10 


Source 
Southern African 2001 

—————————————————————————————————————————————————— 
Floyd-Warshall算法是解決任意兩點間的最短路徑的一種算法,可以正確處理有向圖(Directed Graph)或負數的代價(negtive cost)的最短路徑問題。Floyd-Warshall算法的時間復雜度為<math>O(N^3)</math>。 
 Floyd-Warshall算法的描述如下: 
 
for k  1 to n do
  for i  1 to n do  
    for j  1 to n do
      if (<math>D_{i,k} + D_{k,j} < D_{i,j}</math>) then      
          <math>D_{i,j}</math>  <math>D_{i,k} + D_{k,j}</math>; 
 
其中<math>D_{i,j}</math>表示由點<math>i</math>到點<math>j</math>的代價(cost),當<math>D_{i,j}</math>為 ∞ 表示兩點之間沒有任何連接(Disconnected)。 

Floyd算法也可以說是動態規劃。 


Source
Problem Id:1125  User Id:lnmm 

Memory:84K  Time:0MS 
Language:C++  Result:Accepted 

 1#include"stdio.h" 
 2int a[101][101]; 
 3int i,j,k=0
 4int min; 
 5int max[101]; 
 6int T; 
 7int n,m,temp,to; 
 8int flag; 
 9void main() 
10
11while(scanf("%d",&n)&&n!=0)    //讀入一個set的人數 
12
13       for(i=1;i<=n;i++
14     for(j=1;j<=n;j++
15        a[i][j]=32767
16  for(i=1;i<=n;i++
17   a[i][i]=0;              //初識化該set的矩陣 
18  for(i=1;i<=n;i++)           //讀入一個set的數據 
19  
20   scanf("%d",&m); 
21   for(j=1;j<=m;j++
22   
23    scanf("%d %d",&to,&temp); 
24    a[i][to]=temp; 
25   }
 
26  }
 
27  for(k=1;k<=n;k++)             //弗洛伊德算法 
28   for(i=1;i<=n;i++
29    for(j=1;j<=n;j++
30    
31     if(a[i][k]!=32767 && a[k][j]!=32767 && a[i][j]>a[i][k]+a[k][j]) 
32      a[i][j]=a[i][k]+a[k][j]; 
33    }
 
34
35         
36  flag=0
37  for(i=1;i<=n;i++)                        //求出從i人開始,謠言傳遞需要的時間 
38  {   max[i]=0
39   for(j=1;j<=n;j++
40   
41    if(max[i]<a[i][j])max[i]=a[i][j]; 
42   }
 
43       
44  }
 
45   
46  min=32767;                                //計算最小謠言時間
47  for(i=1;i<=n;i++
48   if(min>max[i]) 
49   {min=max[i]; 
50   k=i; 
51   }
 
52  if(min==32767)printf("disjoint.\n");            
53  else printf("%d %d\n",k,min); 
54
55   
56}
 
57     
58}


 

posted on 2007-09-14 02:00 流牛ζ木馬 閱讀(1839) 評論(2)  編輯 收藏 引用

評論

# re: ACM PKU 1125 Stockbroker Grapevine 圖論 Floyd算法 2009-05-10 13:12 朱一帆

我說樓主啊,你能不能不要那么自大啊,你的程序的結果是WA啊!!!  回復  更多評論   

# re: ACM PKU 1125 Stockbroker Grapevine 圖論 Floyd算法 2009-05-14 00:09 zx

果然是WA,樓主,要改改啦!  回復  更多評論   

<2009年5月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

導航

統計

公告

MY Email/MSN :mars1021@163.com QQ : 27402040 流牛ζ木馬

常用鏈接

留言簿(6)

隨筆檔案

相冊

搜索

最新隨筆

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲成人自拍视频| 亚洲欧美国产va在线影院| 午夜国产精品影院在线观看| 欧美激情亚洲| 久久综合色8888| 韩国精品在线观看| 国产精品99久久久久久www| 一区二区激情视频| 亚洲国产欧美国产综合一区| 欧美成人午夜77777| 亚洲高清在线精品| 欧美高清视频免费观看| 久久婷婷av| 亚洲乱码一区二区| 亚洲精品一区在线| 欧美日韩影院| 亚洲欧美高清| 午夜精品视频| 国产精品一卡| 久久久精品免费视频| 久久国产精品一区二区| 韩国成人福利片在线播放| 美女黄毛**国产精品啪啪| 免费在线看一区| 狠久久av成人天堂| 一本色道久久88亚洲综合88| 一区二区三区蜜桃网| 国产欧美日韩精品一区| 久久这里只精品最新地址| 91久久精品国产91久久性色tv| 亚洲国产精品久久久久秋霞不卡 | 亚洲第一搞黄网站| 男女av一区三区二区色多| 欧美国产第一页| 亚洲欧美日韩在线播放| 久久精品国产亚洲高清剧情介绍| 亚洲高清av在线| 99国产麻豆精品| 国产自产v一区二区三区c| 91久久线看在观草草青青| 欧美激情中文字幕在线| 一区二区精品| 一区二区三区高清在线观看| 国产午夜精品福利 | 亚洲国产高清在线| 中文国产成人精品| 曰韩精品一区二区| 中文国产亚洲喷潮| 亚洲成人资源| 亚洲专区一区二区三区| 亚洲激情社区| 欧美在线一二三区| 亚洲一区三区电影在线观看| 久久五月激情| 久久精品卡一| 欧美激情精品久久久久| 欧美中文字幕视频| 欧美三日本三级少妇三99| 免费成人高清在线视频| 国产精品嫩草影院av蜜臀| 欧美黄色小视频| 国产日韩一区二区| 一区二区三区 在线观看视| 亚洲国产成人在线视频| 欧美制服丝袜| 欧美亚洲免费在线| 欧美日韩高清在线一区| 久久久久.com| 国产欧美一区视频| 亚洲永久字幕| 午夜精品久久久久99热蜜桃导演| 99伊人成综合| 欧美激情一区二区三区成人| 亚洲成人自拍视频| 影音先锋中文字幕一区二区| 在线一区视频| 亚洲无限乱码一二三四麻| 欧美激情网友自拍| 亚洲国产精品激情在线观看| 亚洲国产综合在线| 久久久欧美精品| 老鸭窝91久久精品色噜噜导演| 国产精品入口夜色视频大尺度| 日韩午夜激情电影| 日韩一级在线| 欧美日韩一区在线视频| 99综合在线| 亚洲自拍三区| 国产日韩亚洲欧美精品| 性欧美xxxx视频在线观看| 亚洲午夜羞羞片| 欧美中文字幕久久| 欧美在线观看天堂一区二区三区| 国产精品久久久久一区二区三区| 在线一区免费观看| 性做久久久久久久久| 国产精品一区二区三区观看| 午夜精品美女久久久久av福利| 香蕉乱码成人久久天堂爱免费 | 99国产精品99久久久久久粉嫩| 亚洲深夜激情| 国产乱码精品一区二区三| 午夜综合激情| 欧美不卡激情三级在线观看| 国产一区二区久久久| 香港久久久电影| 欧美国产综合视频| 亚洲第一伊人| 欧美电影在线观看完整版| 欧美成人性网| 99re66热这里只有精品4| 欧美欧美在线| 亚洲欧美日韩精品久久亚洲区| 久久天天躁狠狠躁夜夜av| 亚洲激情另类| 国产精品红桃| 久久嫩草精品久久久精品| 欧美国产日本在线| 亚洲一区二区少妇| 狠狠久久亚洲欧美专区| 欧美精品日韩三级| 欧美影院成人| 一本一道久久综合狠狠老精东影业| 久久精品30| 亚洲网站在线观看| 在线观看日韩专区| 欧美午夜a级限制福利片| 久久婷婷丁香| 亚洲一级黄色片| 性欧美1819性猛交| 亚洲人人精品| 国产最新精品精品你懂的| 欧美天天在线| 欧美成人免费一级人片100| 亚洲欧美综合| 亚洲一级一区| 亚洲人体一区| 欧美大片va欧美在线播放| 欧美呦呦网站| 亚洲一区激情| 99国产精品99久久久久久粉嫩| 狠狠色综合色综合网络| 国产精品男人爽免费视频1| 久久网站免费| 亚洲欧美一级二级三级| 亚洲经典一区| 亚洲国产福利在线| 欧美成人免费在线观看| 久久久夜精品| 久久久久久久网| 午夜久久电影网| 亚洲综合日韩| 亚洲视频综合| 亚洲午夜三级在线| 一区二区高清视频在线观看| 亚洲精品在线免费观看视频| 在线观看日韩精品| 一区视频在线播放| 黄色成人av| 国语精品一区| 在线精品亚洲一区二区| 国语自产在线不卡| 国产精品亚洲第一区在线暖暖韩国| 欧美日韩国产丝袜另类| 欧美日韩成人综合| 欧美日韩国产成人在线91| 欧美日本中文字幕| 欧美精品麻豆| 国产九九精品视频| 亚洲国产另类久久久精品极度| 一区二区三区蜜桃网| 欧美在线高清| 亚洲欧洲综合另类| 亚洲一区二区三区乱码aⅴ蜜桃女 亚洲一区二区三区乱码aⅴ | 国内精品国产成人| 亚洲精品综合精品自拍| 香港成人在线视频| 欧美高清在线| 亚洲在线免费视频| 男人的天堂成人在线| 国产精品久久久久久久久久免费| 国产亚洲精品v| 一级日韩一区在线观看| 久久裸体艺术| 亚洲视频中文字幕| 美女主播精品视频一二三四| 欧美色图五月天| 亚洲国产精品久久久久久女王| 羞羞答答国产精品www一本| 欧美激情国产精品| 欧美专区在线观看| 欧美午夜精彩| 99精品国产在热久久婷婷| 久久色中文字幕| 亚洲综合精品自拍| 欧美日韩在线一区| 亚洲美女在线一区| 欧美成人久久| 久久蜜桃精品| 一区二区三区我不卡|