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

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>
            国产精品影院在线观看| 日韩亚洲国产欧美| 日韩视频精品| 亚洲区一区二区三区| 欧美一区二区免费| 亚洲免费网址| 欧美日韩成人| 亚洲激情一区二区| 亚洲第一搞黄网站| 欧美在线资源| 久久精品一区二区三区中文字幕| 欧美午夜视频在线| 日韩视频一区| 一本色道婷婷久久欧美| 欧美成人中文字幕| 亚洲高清免费在线| 在线免费观看一区二区三区| 久久狠狠婷婷| 麻豆精品国产91久久久久久| 狠狠色丁香婷婷综合影院| 性欧美1819性猛交| 久久精品日韩欧美| 精品不卡一区| 老司机午夜精品视频| 欧美成人免费网站| 亚洲国产日韩欧美| 欧美激情亚洲自拍| 99亚洲一区二区| 亚洲欧美在线免费观看| 国产日韩欧美精品一区| 欧美一区二区三区另类| 久久综合伊人77777| 激情久久久久久| 免费在线成人av| 亚洲日韩成人| 亚洲欧美一区二区三区久久| 国产精品有限公司| 久久久久国色av免费观看性色| 麻豆免费精品视频| 91久久精品视频| 欧美日韩和欧美的一区二区| 一区二区三区精品久久久| 欧美在线免费| 91久久亚洲| 国产精品久久久久久久久久尿| 午夜欧美精品| 欧美成人午夜影院| 亚洲一区二区三区四区中文| 国产伦精品一区二区三区| 久久精品国产一区二区三| 亚洲国产精品成人综合| 亚洲一区二区三区中文字幕| 国产午夜亚洲精品理论片色戒| 久久男人av资源网站| 亚洲精品综合精品自拍| 欧美一区免费视频| 亚洲黄色免费| 国产精品三级视频| 欧美h视频在线| 亚洲欧美美女| 亚洲国产精品久久久久秋霞不卡| 亚洲午夜三级在线| 影院欧美亚洲| 欧美午夜在线观看| 猛干欧美女孩| 亚洲欧美日韩精品久久亚洲区 | 久久久久久久97| 亚洲日韩第九十九页| 久久久久中文| 亚洲欧美日韩高清| 日韩视频专区| 好看不卡的中文字幕| 欧美三级特黄| 欧美成人午夜激情在线| 午夜久久电影网| 亚洲毛片在线免费观看| 欧美福利在线观看| 久久久精品免费视频| 亚洲无人区一区| 亚洲精品免费在线| 影音先锋亚洲电影| 国产亚洲精品成人av久久ww| 欧美三级在线播放| 欧美激情精品久久久久| 久久久噜噜噜久久人人看| 亚洲永久在线| 一区二区三区久久久| 亚洲韩日在线| 欧美高清在线| 免费试看一区| 久久综合久久综合久久综合| 香蕉亚洲视频| 亚洲欧美激情视频| 亚洲一二三区精品| 正在播放欧美视频| av成人天堂| 日韩一区二区免费高清| 亚洲国产欧美一区二区三区久久| 国产一区二区欧美| 国产一在线精品一区在线观看| 国产精品欧美经典| 国产精品一二三四| 国产欧美丝祙| 国产日韩一区二区三区在线播放| 国产精品入口日韩视频大尺度| 国产精品v日韩精品v欧美精品网站 | 亚洲精品网站在线播放gif| 欧美成人中文字幕| 亚洲东热激情| 亚洲欧洲中文日韩久久av乱码| 亚洲大片在线| 最新国产乱人伦偷精品免费网站| 亚洲国产高清在线| 亚洲日韩视频| 一本色道久久99精品综合| 亚洲社区在线观看| 午夜一级久久| 久久久久免费观看| 欧美大片va欧美在线播放| 欧美日韩国产一区二区三区地区| 欧美久久99| 国产精品久久久久久久久果冻传媒 | 国产美女扒开尿口久久久| 国产欧美一区二区精品忘忧草| 国产欧美精品va在线观看| 欲色影视综合吧| 亚洲伦理中文字幕| 亚洲砖区区免费| 久久久精品2019中文字幕神马| 麻豆久久精品| 亚洲作爱视频| 亚洲欧美视频在线观看视频| 久久精品国产久精国产思思 | 欧美一站二站| 欧美护士18xxxxhd| 国产精品一香蕉国产线看观看 | 亚洲精品裸体| 亚洲欧美国产日韩天堂区| 久久久夜精品| 日韩视频不卡中文| 欧美一区二区视频网站| 麻豆av一区二区三区| 国产精品九色蝌蚪自拍| 娇妻被交换粗又大又硬视频欧美| 日韩视频不卡| 久久这里有精品15一区二区三区| 亚洲肉体裸体xxxx137| 欧美一区二区三区四区夜夜大片| 免费视频久久| 国产日韩欧美日韩| 夜夜嗨av色综合久久久综合网| 久久久久久精| 亚洲天堂av图片| 欧美成人免费观看| 国产一区二区三区久久久| 日韩午夜av| 暖暖成人免费视频| 午夜欧美不卡精品aaaaa| 欧美另类亚洲| 亚洲国产毛片完整版| 久久激五月天综合精品| 亚洲免费电影在线| 美日韩免费视频| 国产在线观看一区| 亚洲欧美三级在线| 亚洲精品专区| 欧美成人自拍| 亚洲国产一区二区精品专区| 久久精品综合一区| 亚洲一区二区四区| 欧美色大人视频| 日韩午夜电影av| 欧美激情视频一区二区三区在线播放 | 99精品国产福利在线观看免费| 久久夜色精品国产欧美乱极品| 国产日韩欧美一二三区| 亚洲一卡久久| 日韩亚洲欧美综合| 欧美高清视频在线播放| 亚洲国产天堂久久综合网| 老司机一区二区三区| 午夜性色一区二区三区免费视频 | 亚洲开发第一视频在线播放| 每日更新成人在线视频| 久久国内精品视频| 一区二区三区在线视频播放| 久久久精品日韩| 欧美一区二区三区在线观看视频 | 欧美激情视频免费观看| 久久资源av| 亚洲人成人一区二区在线观看| 欧美电影免费观看高清完整版| 久久视频一区| 亚洲级视频在线观看免费1级| 免费日韩视频| 欧美激情欧美激情在线五月| 亚洲人成77777在线观看网| 91久久久在线| 欧美日韩在线观看视频| 亚洲一区二区三区777|