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

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算法是解決任意兩點(diǎn)間的最短路徑的一種算法,可以正確處理有向圖(Directed Graph)或負(fù)數(shù)的代價(jià)(negtive cost)的最短路徑問題。Floyd-Warshall算法的時(shí)間復(fù)雜度為<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>表示由點(diǎn)<math>i</math>到點(diǎn)<math>j</math>的代價(jià)(cost),當(dāng)<math>D_{i,j}</math>為 ∞ 表示兩點(diǎn)之間沒有任何連接(Disconnected)。 

Floyd算法也可以說是動(dòng)態(tài)規(guī)劃。 


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)    //讀入一個(gè)set的人數(shù) 
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;              //初識(shí)化該set的矩陣 
18  for(i=1;i<=n;i++)           //讀入一個(gè)set的數(shù)據(jù) 
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人開始,謠言傳遞需要的時(shí)間 
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;                                //計(jì)算最小謠言時(shí)間
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 流牛ζ木馬 閱讀(1843) 評(píng)論(2)  編輯 收藏 引用

評(píng)論

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

我說樓主啊,你能不能不要那么自大啊,你的程序的結(jié)果是WA啊!!!  回復(fù)  更多評(píng)論   

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

果然是WA,樓主,要改改啦!  回復(fù)  更多評(píng)論   


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2009年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

導(dǎo)航

統(tǒng)計(jì)

公告

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

常用鏈接

留言簿(6)

隨筆檔案

相冊(cè)

搜索

最新隨筆

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美国产另类| 欧美bbbxxxxx| 欧美电影免费观看高清| 亚洲免费视频中文字幕| 亚洲深夜福利视频| 一区二区三区视频在线| 亚洲无线视频| 亚洲校园激情| 欧美在线免费视屏| 久久久999| 欧美va亚洲va国产综合| 免费日韩av电影| 欧美激情按摩| 亚洲一区二区影院| 欧美在线观看一区| 欧美成年人网| 国产精品久久久99| 国产精品99久久不卡二区| 亚洲三级国产| 亚洲久色影视| 亚洲欧美国产高清va在线播| 久久久亚洲国产天美传媒修理工 | 欧美色精品在线视频| 欧美日韩免费高清| 国产欧美一区二区精品秋霞影院| 国产视频在线观看一区二区| 黄色成人av网| 亚洲乱码国产乱码精品精可以看 | 欧美日韩精品一区二区天天拍小说| 欧美日本三区| 国产亚洲综合在线| 一区二区欧美国产| 免费观看一区| 中文一区在线| 另类激情亚洲| 国产亚洲精品久久久| 99视频国产精品免费观看| 久久精品论坛| 一区二区三区高清视频在线观看| 久久久天天操| 国产精品夫妻自拍| 亚洲最新在线视频| 欧美电影电视剧在线观看| 亚洲欧美色一区| 国产精品久久99| 一区二区三区四区精品| 久久久久久久综合日本| 99视频一区二区| 欧美jizz19hd性欧美| 国产视频亚洲| 亚洲一区二区在| 日韩亚洲视频| 欧美日韩午夜| 一区二区日韩伦理片| 亚洲国产日韩精品| 免费在线观看日韩欧美| 国产亚洲精品bt天堂精选| 亚洲一区二区动漫| 亚洲美女中出| 欧美午夜视频网站| 午夜精品一区二区三区在线视| avtt综合网| 国产精品三级视频| 亚洲在线免费观看| 一区二区欧美精品| 国产精品久久二区| 性8sex亚洲区入口| 黑人一区二区| 久久综合九色综合久99| 久久蜜桃资源一区二区老牛| 亚洲视频在线免费观看| 最近看过的日韩成人| 欧美激情一区二区三区在线| 在线免费观看日韩欧美| 欧美成人在线影院| 欧美日韩精品综合在线| 欧美一区网站| 麻豆精品传媒视频| 亚洲无线视频| 久久久欧美精品| 亚洲美女黄网| 亚洲欧美日韩在线观看a三区| 精品动漫一区二区| 亚洲欧洲日产国码二区| 国产精品久久久久三级| 久久久伊人欧美| 亚洲欧美国产va在线影院| 国产一区二区三区在线播放免费观看| 久久久综合香蕉尹人综合网| 久久人人爽人人爽| 亚洲精品在线电影| 亚洲综合色在线| 亚洲精美视频| 亚洲一区二区三区高清 | 国产日韩欧美亚洲| 模特精品在线| 国产精品亚洲成人| 亚洲国产精品传媒在线观看| 国产精品xxx在线观看www| 久久久久久亚洲精品杨幂换脸 | 影音先锋日韩有码| 在线视频一区观看| 亚洲国产成人tv| 亚洲一区二区在线播放| 亚洲国产精品久久91精品| 一区二区三区**美女毛片| 在线成人激情| 香蕉成人伊视频在线观看| 亚洲精品乱码久久久久久黑人| 亚洲一区二区伦理| 夜夜嗨av色综合久久久综合网| 亚洲自拍三区| 亚洲午夜视频| 欧美日韩一区二区免费视频| 日韩视频一区二区三区在线播放| 香蕉免费一区二区三区在线观看| 一本色道久久综合狠狠躁篇怎么玩 | 国产日韩视频一区二区三区| 亚洲电影欧美电影有声小说| 欧美中文字幕视频| 亚洲国产一区二区在线| 亚洲在线观看免费| 一本久道久久综合婷婷鲸鱼| 久久中文久久字幕| 久久综合伊人77777蜜臀| 国产欧美日韩在线视频| 亚洲天堂av综合网| 亚洲视频观看| 欧美日韩三级在线| 亚洲精品免费电影| 妖精成人www高清在线观看| 猛男gaygay欧美视频| 欧美成年人网| 亚洲国产黄色| 欧美a级一区二区| 欧美激情成人在线| 亚洲国产成人不卡| 欧美成人资源网| 91久久香蕉国产日韩欧美9色 | 日韩小视频在线观看专区| 久久青草欧美一区二区三区| 老司机aⅴ在线精品导航| 激情成人综合| 毛片一区二区| 最新日韩中文字幕| 亚洲私人影吧| 国产老肥熟一区二区三区| 亚洲欧美日韩在线一区| 久久亚洲二区| 亚洲精品一二区| 欧美日韩三区| 欧美一级视频一区二区| 久久夜色精品国产欧美乱极品 | 欧美一级网站| 黄页网站一区| 欧美精品久久久久久久久久| 亚洲国产日韩欧美| 亚洲一区视频在线观看视频| 国产精品一区二区在线观看不卡| 亚洲欧美日韩综合aⅴ视频| 久久综合国产精品台湾中文娱乐网| 黄色精品一二区| 欧美人交a欧美精品| 亚洲欧美日本另类| 欧美成人官网二区| 一区二区三区免费在线观看| 国产精品日韩精品欧美精品| 久久久久久网址| 日韩图片一区| 久久蜜桃av一区精品变态类天堂| 91久久国产综合久久91精品网站| 欧美日韩网站| 开元免费观看欧美电视剧网站| 一本色道久久99精品综合| 久久久亚洲国产天美传媒修理工 | 日韩视频免费观看| 国产亚洲精品福利| 欧美日韩视频在线第一区| 久久精品久久综合| 99香蕉国产精品偷在线观看| 久久人人爽人人爽爽久久| 欧美揉bbbbb揉bbbbb| 久久精品国产免费观看| 亚洲美女在线一区| 欧美国产免费| 久久国产手机看片| 亚洲私人黄色宅男| 亚洲日本免费| 激情一区二区三区| 国产日韩欧美亚洲一区| 欧美视频一区在线| 欧美国产一区二区三区激情无套| 欧美在线欧美在线| 亚洲视频免费在线| 亚洲美女精品久久| 亚洲人妖在线| 亚洲国产欧美一区二区三区久久 | 国产精品入口福利| 欧美午夜片在线观看| 欧美日韩www|