hdu5173 How Many Maos Does the Guanxi Worth
- #include<bits/stdc++.h>
- using namespace std;
- #define INF 0x3f3f3f3f
- int dis[];
- int visit[];
- int SSSP[][];
- void dijkstra(int x,int n)
- {
- int pos;
- int minn;
- for(int i=;i<=n;i++)
- {
- dis[i]=SSSP[][i];
- }
- visit[x]=;
- dis[x]=;
- for(int i=;i<=n;i++)
- {
- minn=INF;
- pos=;
- for(int j=;j<=n;j++)
- {
- if(!visit[j]&&dis[j]<minn)
- {
- pos=j;
- minn=dis[j];
- }
- }
- if(pos==) break;
- else
- {
- visit[pos]=;
- for(int j=;j<=n;j++)
- {
- if(!visit[j]&& dis[pos]+SSSP[pos][j]<dis[j])
- dis[j]=dis[pos]+SSSP[pos][j];
- }
- }
- }
- }
- int main()
- {
- while()
- {
- int n,m; cin>>n>>m;
- if(n==&&m==) break; int zzzzz=;
- memset(visit,,sizeof(visit));
- memset(dis,,sizeof(dis));
- memset(SSSP,,sizeof(SSSP));
- for(int i=;i<=n;i++)
- {
- for(int j=;j<=n;j++)
- SSSP[i][j]=INF;
- }
- int a[];
- int b[];
- int t[];
- for(int i=;i<=m;i++)
- {
- cin>>a[i]>>b[i]>>t[i];
- SSSP[a[i]][b[i]]=t[i];
- SSSP[b[i]][a[i]]=t[i];
- }
- dijkstra(,n); //cout<<"*****"<<dis[n]<<"*******"<<zzzzz<<"******"<<endl;
- if(dis[n]==INF)
- {
- zzzzz=;
- }
- int maxn=dis[n];
- for(int i=;i<n;i++)
- {
- // qu dian chong ding yi
- if(zzzzz==) break;
- for(int j=;j<=n;j++)
- {
- for(int j1=;j1<=n;j1++)
- SSSP[j][j1]=INF;
- }
- for(int j=;j<=m;j++)
- {
- SSSP[a[j]][b[j]]=t[j];
- SSSP[b[j]][a[j]]=t[j];
- if(a[j]==i||b[j]==i)
- {
- SSSP[a[j]][b[j]]=INF;
- SSSP[b[j]][a[j]]=INF;
- }
- }
- // chong ding yi visit[] dis
- memset(visit,,sizeof(visit));
- memset(dis,,sizeof(dis));
- dijkstra(,n); // cout<<"*****"<<dis[n]<<"*******"<<zzzzz<<"******"<<endl;
- if(dis[n]==INF)
- {
- zzzzz=;
- }
- if(dis[n]>maxn) maxn=dis[n];
- }
- if(zzzzz==)
- cout<<maxn<<endl;
- if(zzzzz==)
- cout<<"Inf"<<endl;
- }
- }
hdu5173 How Many Maos Does the Guanxi Worth的更多相关文章
- hdu 5137 How Many Maos Does the Guanxi Worth 最短路 spfa
How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5 ...
- HDU 5137 How Many Maos Does the Guanxi Worth
How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5120 ...
- hdoj 5137 How Many Maos Does the Guanxi Worth【最短路枚举+删边】
How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5 ...
- HDU5137 How Many Maos Does the Guanxi Worth(枚举+dijkstra)
How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5 ...
- How Many Maos Does the Guanxi Worth
How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5 ...
- HDU 5137 How Many Maos Does the Guanxi Worth 最短路 dijkstra
How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5 ...
- (hdoj 5137 floyd)How Many Maos Does the Guanxi Worth
How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5 ...
- 杭电5137How Many Maos Does the Guanxi Worth
How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5 ...
- ACM学习历程——HDU5137 How Many Maos Does the Guanxi Worth(14广州10题)(单源最短路)
Problem Description "Guanxi" is a very important word in Chinese. It kind of means &quo ...
随机推荐
- laravel文件上传(本人使用的ftp驱动配置,本地测试总结)
1.电脑端在:控制面板->程序和功能->打开和关闭Window功能,安装:Internet信息服务的(Ftp服务器,web管理工具的IIS管理服务,万网服务的常见http功能) 2.在电脑 ...
- Win10系列:JavaScript 动画1
在应用程序中使用动画会使应用显得更加生动,进而给用户带来良好的视觉效果.例如,当用户将某个项添加到列表时,新项不会立即出现在列表中,而是采用动画形式到达相应位置,并且列表中的其他项也采用动画形式移动到 ...
- 微信公众号 access_token 没有过期 却失效
最近在开发微信项目的时候 access_token 缓存到 redis里面的,明明在两个小时的有效期内 微信却提示 "errcode":40001,"errmsg& ...
- learning ddr tRP and tRP tRTP CL tRAS
referce :https://blog.csdn.net/ghostyu/article/details/7728106 tRP(RAS Precharge Time): “内存行地址控制器预充电 ...
- 计算机基础part1
一:计算机的基本组成 1.计算机由输入单元.控制单元.算法逻辑单元.输出单元.存储单元,五大单元组成 二:概念篇 CPU:中央处理器,其内含有指令集(取码-解码-执行的过程) CPU同一时刻只能干一件 ...
- day28 黏包及黏包解决方案
今日主要内容: 一 .缓冲区 二.两种黏包现象 三.黏包现象的两种解决方案 四.打印进度条(补充的,了解即可) 1. 缓冲区 缓冲区的作用 : 将程序和网络解耦(这样做的好处是程序不会以为网速的快慢而 ...
- 浅谈caffe中train_val.prototxt和deploy.prototxt文件的区别
本文以CaffeNet为例: 1. train_val.prototxt 首先,train_val.prototxt文件是网络配置文件.该文件是在训练的时候用的. 2.deploy.prototxt ...
- VSTO:使用C#开发Excel、Word【3】
<Visual Studio Tools for Office: Using C# with Excel, Word, Outlook, and InfoPath >——By Eric C ...
- rnn-手写数字识别-网络结构-shape
手写数字识别经典案例,目标是: 1. 掌握tf编写RNN的方法 2. 剖析RNN网络结构 tensorflow编程 #coding:utf-8 import tensorflow as tf from ...
- Java总结篇系列:Java泛型(转)
一. 泛型概念的提出(为什么需要泛型)? 首先,我们看下下面这段简短的代码: 1 public class GenericTest { 2 3 public static void main(Stri ...