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

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 流牛ζ木馬 閱讀(1852) 評論(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,樓主,要改改啦!  回復  更多評論   


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


<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在线影院| 亚洲欧美精品伊人久久| 开元免费观看欧美电视剧网站| 国产欧美一区二区三区视频| 欧美在线视频不卡| 欧美一区免费视频| 国内精品久久久久影院色 | 欧美午夜精品久久久久久孕妇| 一区二区欧美精品| 亚洲另类视频| 夜夜夜精品看看| 国产婷婷一区二区| 欧美成人综合网站| 欧美日韩精品一区| 久久精品国产久精国产爱| 久久午夜羞羞影院免费观看| 亚洲精品一区二区在线观看| 亚洲网在线观看| 国产一区激情| 亚洲国产美女久久久久| 欧美日韩一区二区在线播放| 羞羞色国产精品| 老司机精品视频网站| 一区二区三区高清在线| 欧美伊久线香蕉线新在线| 91久久国产自产拍夜夜嗨| 一区二区三区免费观看| 国内成人在线| 日韩网站在线看片你懂的| 国内精品久久久| 亚洲精品视频在线观看免费| 国产亚洲美州欧州综合国| 亚洲人成亚洲人成在线观看| 国产欧美一区二区三区另类精品| 欧美激情中文字幕一区二区| 国产精品亚洲综合色区韩国| 亚洲国产视频直播| 狠狠爱综合网| 在线视频亚洲| 日韩天堂av| 久久精品九九| 欧美在线三区| 国产精品激情偷乱一区二区∴| 免费成人黄色片| 国产日产高清欧美一区二区三区| 亚洲日本成人| 亚洲国产精品va在看黑人| 亚洲欧美三级伦理| 国内激情久久| 午夜精品免费| 亚洲午夜羞羞片| 欧美粗暴jizz性欧美20| 久久综合色88| 国产手机视频精品| 亚洲视频在线视频| 一本色道久久综合一区| 母乳一区在线观看| 欧美jjzz| 亚洲成人在线网站| 久久久精品日韩欧美| 久久精品麻豆| 国产曰批免费观看久久久| 国产精品99久久99久久久二8 | 中文精品一区二区三区 | 夜夜嗨av一区二区三区中文字幕 | 久久午夜电影| 国产一区二区三区日韩| 欧美亚洲一级片| 久久精品综合一区| 国产一区二区电影在线观看| 午夜精品免费| 久久久久久9999| 精品9999| 欧美a级理论片| 亚洲全部视频| 在线视频欧美一区| 欧美日韩在线一区二区三区| 99视频精品| 老牛嫩草一区二区三区日本| 一本色道久久加勒比88综合| 久久视频在线免费观看| 国产精品老女人精品视频| 亚洲天堂av在线免费观看| 亚洲欧美春色| 国产在线高清精品| 久久久一本精品99久久精品66| 亚洲高清不卡在线| 欧美国产日韩一区| avtt综合网| 久久久久国产一区二区| 亚洲国产精品一区制服丝袜| 欧美黄色网络| 亚洲欧美国产三级| 久久尤物视频| 一区二区三区波多野结衣在线观看| 国产精品福利网| 久久av红桃一区二区小说| 欧美高清视频一二三区| 亚洲一区精品视频| 伊人久久婷婷色综合98网| 欧美日韩高清免费| 欧美综合国产| 99精品国产在热久久下载| 久久精品综合网| avtt综合网| 国产一区二区毛片| 欧美伦理91i| 久久九九国产| 亚洲一区二区三区四区五区午夜| 美女在线一区二区| 亚洲综合色激情五月| 亚洲国产免费| 国产日韩欧美精品综合| 欧美日韩成人在线视频| 欧美在线一级视频| 一区二区免费在线播放| 欧美激情视频网站| 久久激情五月丁香伊人| 亚洲午夜电影在线观看| 亚洲欧洲中文日韩久久av乱码| 国产精品色在线| 欧美日韩精品免费观看| 久久综合久久88| 亚欧成人在线| 亚洲曰本av电影| 日韩视频一区| 亚洲国产毛片完整版| 久久人人爽人人爽爽久久| 亚洲欧美日韩另类精品一区二区三区| 亚洲狼人精品一区二区三区| 一区二区三区亚洲| 国产亚洲精品成人av久久ww| 国产精品久久久久久久久久免费| 欧美激情一二三区| 欧美99久久| 麻豆freexxxx性91精品| 久久久噜噜噜久久中文字幕色伊伊| 亚洲欧美成人网| 亚洲综合色婷婷| 亚洲一区二区三区高清不卡| 9色精品在线| 夜夜精品视频一区二区| 亚洲剧情一区二区| 日韩视频在线观看一区二区| 亚洲区免费影片| 亚洲精品日韩一| 亚洲精品中文字幕女同| 亚洲免费观看视频| 日韩午夜电影在线观看| 一区二区三区精品| 亚洲视频中文| 午夜国产不卡在线观看视频| 午夜一区在线| 久久精品盗摄| 毛片精品免费在线观看| 欧美激情1区| 欧美日韩国产在线| 国产精品美女久久久久久2018| 国产精品日韩二区| 国产一区二区三区四区在线观看 | 一区二区免费在线视频| 一区二区三区高清在线| 亚洲自拍16p| 久久不射2019中文字幕| 久久综合电影一区| 欧美激情va永久在线播放| 欧美视频二区36p| 国产婷婷色一区二区三区| 黑人极品videos精品欧美裸| 91久久国产自产拍夜夜嗨| 夜夜嗨av一区二区三区四区| 亚洲欧美日韩区| 久久午夜羞羞影院免费观看| 亚洲国产日韩一级| 亚洲影视综合| 鲁大师成人一区二区三区| 欧美日韩一区精品| 国产一区二区久久精品| 亚洲精品永久免费精品| 欧美一区日韩一区| 欧美国产成人精品| 亚洲一级黄色| 你懂的国产精品| 国产精品丝袜久久久久久app| 一区二区在线观看av| 亚洲视频www| 女同一区二区| 亚洲图片欧美午夜| 欧美成年人视频网站| 国产麻豆综合| 一区二区三欧美| 久久这里有精品视频| 在线视频你懂得一区二区三区| 久久久水蜜桃| 国产精品色婷婷| 一区二区三区四区国产精品| 六十路精品视频| 亚洲欧美激情精品一区二区| 欧美第一黄色网| 在线观看日韩av电影|