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

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>
            亚洲欧美清纯在线制服| 美女视频网站黄色亚洲| 亚洲精品专区| 欧美日韩精品在线观看| 中日韩视频在线观看| 日韩亚洲在线| 国产精品一二一区| 久久久久国产精品www| 久久精品亚洲一区二区| 亚洲福利视频专区| 亚洲国产精品一区二区www在线 | 香蕉精品999视频一区二区| 一个色综合av| 国产丝袜一区二区三区| 男人插女人欧美| 欧美久久久久久蜜桃| 亚洲一区二区日本| 欧美中文在线观看国产| 亚洲国产另类久久精品| 日韩视频一区二区三区在线播放免费观看 | 欧美在线视频观看| 亚洲国产日韩综合一区| 夜夜嗨一区二区三区| 国产欧美日韩专区发布| 欧美激情亚洲精品| 国产精品久久久久7777婷婷| 久久久一区二区| 欧美日韩在线播放| 久久噜噜噜精品国产亚洲综合| 欧美夫妇交换俱乐部在线观看| 亚洲欧美三级在线| 欧美成人综合| 久久精品一区| 欧美性大战久久久久久久| 每日更新成人在线视频| 国产精品xnxxcom| 欧美国产日韩一区二区三区| 国产精品专区第二| 亚洲欧洲精品成人久久奇米网| 国产视频精品xxxx| 一区二区三区视频在线看| 亚洲国产精品悠悠久久琪琪| 亚洲欧美日韩精品久久奇米色影视| 亚洲黄色大片| 久久久久成人精品免费播放动漫| 亚洲午夜久久久| 欧美福利小视频| 欧美xxxx在线观看| 狠狠色综合网站久久久久久久| 亚洲视频导航| aa亚洲婷婷| 欧美国产综合| 欧美国产精品久久| 在线成人h网| 久久国产精品一区二区三区四区| 午夜精品亚洲| 国产精品美女久久久久久2018| 亚洲精品一区中文| 亚洲精选国产| 欧美国产亚洲视频| 亚洲高清不卡一区| 亚洲精品久久7777| 免费亚洲网站| 亚洲高清一二三区| 亚洲免费观看高清完整版在线观看熊| 久久久久久999| 裸体素人女欧美日韩| 韩国精品在线观看| 久久久久国产精品一区三寸| 老司机免费视频久久 | 久久久之久亚州精品露出| 久久狠狠亚洲综合| 国产一区视频在线观看免费| 午夜精品免费| 久久先锋影音| 亚洲欧洲日韩女同| 欧美另类专区| 亚洲视频精品在线| 久久国产一区二区| 尤物精品在线| 欧美3dxxxxhd| 日韩视频―中文字幕| 亚洲直播在线一区| 国产午夜亚洲精品理论片色戒| 久久成人免费网| 欧美国产视频在线| 一本久久a久久免费精品不卡| 欧美色一级片| 欧美一站二站| 亚洲成人在线网| 欧美一区二区三区精品电影| 久久久久久久综合| 亚洲日本精品国产第一区| 欧美日韩国产精品一区| 亚洲一区免费观看| 美女在线一区二区| 亚洲图片欧洲图片av| 国产日产高清欧美一区二区三区| 久久精品夜色噜噜亚洲aⅴ| 亚洲国产精品一区在线观看不卡 | 在线视频亚洲一区| 国产欧美日韩在线观看| 麻豆国产精品一区二区三区| 99re国产精品| 欧美.www| 亚洲欧美日韩国产精品| 亚洲国产精品一区二区www| 欧美午夜精品久久久久久久 | 99热免费精品在线观看| 麻豆av福利av久久av| 亚洲一二三区在线| 亚洲成人影音| 国产精品一区2区| 欧美1区2区| 久久久91精品国产一区二区三区| 亚洲精品日本| 欧美国产精品人人做人人爱| 性伦欧美刺激片在线观看| 亚洲美女视频| 曰韩精品一区二区| 国产乱人伦精品一区二区 | 欧美美女视频| 久久久综合免费视频| 亚洲性视频h| 亚洲免费精品| 亚洲精品国产日韩| 欧美11—12娇小xxxx| 久久精品国产v日韩v亚洲| 在线视频欧美精品| 亚洲精品国产精品国自产观看浪潮| 国产亚洲欧美另类中文 | 久久精品国产欧美亚洲人人爽| 日韩一级欧洲| 亚洲精品美女免费| 亚洲高清毛片| 亚洲第一天堂av| 欧美+日本+国产+在线a∨观看| 久久不射2019中文字幕| 午夜精品一区二区三区在线播放| 一本色道久久综合狠狠躁篇怎么玩| 亚洲国产天堂久久国产91| 激情小说亚洲一区| 伊人激情综合| 亚洲精品1区2区| 亚洲经典自拍| 99re在线精品| 一区二区三区波多野结衣在线观看| 亚洲精品视频在线观看免费| 亚洲国产日韩欧美在线图片| 亚洲国产三级网| 亚洲精品系列| 亚洲一区二区成人在线观看| 一本一本a久久| 亚洲在线播放| 久久av红桃一区二区小说| 久久久久久久久久久久久久一区 | 美女日韩在线中文字幕| 老司机午夜精品视频在线观看| 久久视频在线视频| 牛牛精品成人免费视频| 亚洲观看高清完整版在线观看| 亚洲国产高清一区| 99精品视频免费观看| 亚洲午夜久久久久久久久电影院 | 欧美色图五月天| 国产精品自拍在线| 精品999成人| 亚洲人成精品久久久久| 一区二区黄色| 久久精品免费| 亚洲二区视频在线| 99伊人成综合| 欧美综合77777色婷婷| 欧美va天堂在线| 国产精品每日更新| 永久91嫩草亚洲精品人人| 日韩视频在线免费观看| 午夜影院日韩| 欧美jizzhd精品欧美喷水| 日韩一区二区电影网| 欧美在线黄色| 欧美日韩在线一区| 一区二区自拍| 午夜久久久久| 亚洲第一视频| 欧美一区在线视频| 欧美激情视频网站| 国产亚洲a∨片在线观看| 亚洲精品视频在线| 久久精品一区二区三区不卡牛牛| 欧美激情久久久| 欧美一区二区精品在线| 欧美日韩国产成人在线91| 韩国三级电影一区二区| 亚洲免费在线观看| 亚洲欧洲精品一区二区三区 | 久久gogo国模裸体人体| 欧美视频一区二区三区…| 亚洲国产视频一区| 久久久久一本一区二区青青蜜月|