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

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>
            国产欧美午夜| 亚洲国产精品久久人人爱蜜臀| 欧美日韩成人一区二区| 亚洲第一中文字幕| 亚洲第一精品夜夜躁人人爽| 欧美一区视频| 国产精品www994| 99精品黄色片免费大全| 在线一区二区三区四区五区| 亚洲国产女人aaa毛片在线| 国产精品99久久久久久久久| 亚洲国产精品123| av成人免费观看| 亚洲少妇中出一区| 国产精品v欧美精品v日本精品动漫| 欧美第十八页| 国产欧美一区二区精品仙草咪 | 亚洲永久在线观看| 亚洲第一精品久久忘忧草社区| 99伊人成综合| 久久久免费av| 午夜精品久久久久久久99樱桃| 亚洲一区综合| 免费看成人av| 欧美日韩a区| 久久婷婷成人综合色| 亚洲愉拍自拍另类高清精品| 亚洲欧美国产三级| 亚洲在线电影| 亚洲一区二区精品| 亚洲一区二区三区四区视频| 国产欧美一区二区精品性色| 午夜国产欧美理论在线播放| 一区二区三区精品视频在线观看| 免费观看成人| 久久综合色播五月| 亚洲精品一区二区三区樱花| 亚洲精品资源| 国产精品一区=区| 久久久国产一区二区三区| 久久不见久久见免费视频1| 在线观看一区视频| 亚洲人成小说网站色在线| 欧美一区二区精美| 国产精品亚洲激情| 亚洲电影专区| 激情欧美一区| 午夜综合激情| 艳女tv在线观看国产一区| 午夜视频在线观看一区| 麻豆精品在线播放| 亚洲成色777777女色窝| 亚洲欧洲日本mm| 亚洲精品免费在线| 一区二区三区高清| 国产麻豆视频精品| 欧美成人精品高清在线播放| 欧美高清在线精品一区| 午夜精品久久久久久久久| 久久精品欧美| 亚洲综合国产精品| 久久综合婷婷| 性xx色xx综合久久久xx| 老司机精品视频一区二区三区| 国产日韩精品在线| 国内欧美视频一区二区| 久久福利资源站| 母乳一区在线观看| 亚洲国产精品一区二区第一页| 国产日韩欧美中文| 亚洲尤物影院| 亚洲精品影视| 午夜精品久久久久久| 国产精品国产三级国产专区53| 99精品热视频只有精品10| 欧美一区二区三区四区视频| 亚洲特级片在线| 亚洲精品视频一区| 国产精品久久久久久久久久ktv | 亚洲一区在线看| 欧美freesex8一10精品| 久久天天躁狠狠躁夜夜av| 国产伦精品免费视频| 狂野欧美一区| 久久影视三级福利片| 亚洲一区二区三区在线播放| 亚洲精品乱码久久久久久蜜桃麻豆| 欧美区在线播放| 老色鬼久久亚洲一区二区| 欧美亚洲系列| 久久精品欧美日韩| 亚洲精选成人| 亚洲精品日韩欧美| 最新国产成人在线观看| 欧美aⅴ一区二区三区视频| 欧美影院一区| 99在线精品视频| 韩国v欧美v日本v亚洲v| 最新日韩在线视频| 久久人体大胆视频| 男人天堂欧美日韩| 在线播放日韩专区| 久久久久国内| 欧美va天堂在线| 最新中文字幕一区二区三区| 久久久综合精品| 欧美本精品男人aⅴ天堂| 亚洲电影一级黄| 欧美成人激情在线| 亚洲精品国产精品国产自| 亚洲精品精选| 欧美日韩一区二区三区在线视频| 日韩一级二级三级| 午夜日韩激情| 狠狠色噜噜狠狠狠狠色吗综合| 久久免费视频观看| 亚洲国产成人久久综合| 夜夜爽99久久国产综合精品女不卡| 国产精品看片资源| 亚洲一区久久久| 免费看精品久久片| 久久夜色精品国产欧美乱极品| 国产一区视频在线看| 欧美亚洲视频一区二区| 美国成人毛片| 欧美成人亚洲成人日韩成人| 欧美电影免费观看高清完整版| 亚洲日本va午夜在线电影| 欧美日韩国产在线播放网站| 亚洲一卡久久| 美女国产一区| 亚洲网站在线观看| 国产一区再线| 欧美片第一页| 久久精品免费| 亚洲最快最全在线视频| 久久福利一区| 99热在这里有精品免费| 国产区亚洲区欧美区| 男女av一区三区二区色多| 亚洲一区二区三| 亚洲国产成人精品久久| 国产色视频一区| 一区二区三区我不卡| 中文无字幕一区二区三区| 午夜视频一区二区| 激情久久久久久久| 欧美伦理一区二区| 久久成人免费日本黄色| 亚洲精品孕妇| 免费成人av资源网| 亚洲一区在线免费| 亚洲精品自在久久| 国产一区再线| 国产精品一卡二卡| 欧美日韩一区二| 久久亚洲春色中文字幕| 亚洲一区日韩在线| 亚洲精品在线免费观看视频| 老鸭窝亚洲一区二区三区| 欧美一区2区三区4区公司二百| 日韩视频一区二区三区| 1000精品久久久久久久久| 国模叶桐国产精品一区| 国产精品视频999| 国产精品久久久久91| 亚洲在线一区二区三区| 亚洲乱码国产乱码精品精| 亚洲二区精品| 欧美激情一区二区三区成人| 久久综合国产精品| 久久久视频精品| 久久久国产精彩视频美女艺术照福利 | 亚洲国产欧美在线人成| 欧美成人综合一区| 免费日韩成人| 麻豆91精品91久久久的内涵| 久久国产日韩| 久久久久国产精品一区三寸| 久久久久久69| 久久午夜电影网| 美女999久久久精品视频| 免费观看成人| 亚洲福利在线看| 亚洲人成在线播放| 亚洲精品美女在线观看| 99re8这里有精品热视频免费| 日韩一区二区福利| 中日韩视频在线观看| 亚洲女人av| 久久久久久夜| 欧美顶级少妇做爰| 欧美日韩大陆在线| 国产精品日韩高清| 国产精品入口66mio| 国产色爱av资源综合区| 亚洲第一色在线| 亚洲国产日韩欧美在线图片| 亚洲精选国产| 午夜欧美视频|