设为首页 加入收藏

TOP

poj-1797 Heavy Transportation
2015-07-20 17:22:52 来源: 作者: 【 】 浏览:1
Tags:poj-1797 Heavy Transportation

?

求所有路径中承载量的最小值的最大值

?

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        using namespace std; const int MAXV = 4010; const int inf = 10000000; int map[MAXV][MAXV]; int d[MAXV]; bool vis[MAXV]; int n,m; void dijkstra(int s) { for(int i=1;i<=n;i++) { vis[i]=0; d[i]=map[s][i]; } while (1) { int minn = 0; int v = -1; for(int i=1;i<=n;i++) if(!vis[i] && d[i] > minn) { v=i; minn=d[i]; } if(v == -1) break; vis[v]=1; for(int i=1;i<=n;i++) if(!vis[i] && d[i] < min(d[v] , map[v][i])) d[i] = min(map[v][i],d[v]); } } int main() { int i,j,a,b,c,t; int cases = 1; scanf(%d,&t); while(t--) { scanf(%d%d,&n,&m); memset(map,0,sizeof(map)); while (m--) { scanf(%d %d %d,&a,&b,&c); map[a][b] = map[b][a] = c; } dijkstra(1); printf(Scenario #%d: ,cases++); printf(%d ,d[n]); } return 0; } 
      
     
    
   
  


?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇UVa 1152 4Values whose Sum is 0 下一篇BZOJ 3198 Sdoi2013 spring Hash+..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Python爬虫教程(从 (2025-12-26 16:49:14)
·【全269集】B站最详 (2025-12-26 16:49:11)
·Python爬虫详解:原 (2025-12-26 16:49:09)
·Spring Boot Java: (2025-12-26 16:20:19)
·Spring BootでHello (2025-12-26 16:20:15)