http://poj.org/problem?id=1125

 #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define MAXN 110
using namespace std;
const int INF=<<;
int dis[MAXN][MAXN];
int n,t,a,b;
void inti()
{
for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
{
dis[i][j]=dis[j][i]=INF;
}
}
}
int main()
{
while(scanf("%d",&n)&&n)
{
inti();
for(int i=; i<=n; i++)
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&a,&b);
dis[i][a]=b;
}
}
for(int k=; k<=n; k++)
{
for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
{
dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
}
}
}
int cc,tt=-,mark=;
for(int i=; i<=n; i++)
{
int t=-,c;
bool flag=true;
for(int j=; j<=n; j++)
{
if(i!=j)
{
if(dis[i][j]==INF)
{
flag=false;
break;
}
else if(dis[i][j]>t)
{
c=i;
t=dis[i][j];
}
}
else continue;
}
if(flag)
{
if(mark)
{
cc=c;
tt=t;
mark=;
}
else if(t<tt)
{
cc=c;
tt=t;
}
}
}
if(tt==-) printf("disjoint\n");
else printf("%d %d\n",cc,tt);
}
return ;
}

最新文章

  1. 构建高可用ZooKeeper集群(转载)
  2. PHP 函数(数组字符串)
  3. 单表60亿记录等大数据场景的MySQL优化和运维之道
  4. 41.Android之图片放大缩小学习
  5. cocos2dx游戏开发——微信打飞机学习笔记(十一)——GameOverScene的搭建
  6. UITableView中cell的圆角(第一个和最后一个)
  7. WP开发笔记——控件倾斜效果
  8. jQuery插件面向对象开发
  9. IE str.trim() 不兼容问题解决方法
  10. ASP.NET通用权限验证组件实现
  11. Windows下载安装jmeter
  12. Linking pronunciation in English
  13. python 3.5构建WINDOWS推送服务
  14. 天兔(Lepus)监控系统快速安装部署
  15. spring事务详解(四)测试验证
  16. Visual Studio Code and local web server
  17. C语言strcmp()实现
  18. html迪士尼网页实现代码
  19. Java:类与对象概念
  20. 如何让win2008服务器显示中文无乱码

热门文章

  1. 三星 note3销售地查询、销售地代码
  2. TeleMCU视频会议之Android版本号WebRTC client支持
  3. 【Deep Learning学习笔记】Dynamic Auto-Encoders for Semantic Indexing_Mirowski_NIPS2010
  4. SCI科技论文写作技巧-核心价值
  5. Protobuf的自动反射消息类型的方法
  6. 笔试之STL
  7. 【转】string常用函数
  8. Python之路,Day13-----暂无正在更新中
  9. Proxy 代理模式
  10. 工厂模式[3] 抽象工厂 Abstract Factory