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