poj_1125 Stockbroker Grapevine

本文深入探讨了当前信息技术领域的核心趋势,包括大数据、人工智能、云计算等前沿技术的发展及其应用案例,为读者提供了全面的技术洞察。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Stockbroker Grapevine

Time Limit: 1000MS

Memory Limit: 10000K

Total Submissions: 20810

Accepted: 11278

题目链接:http://poj.org/problem?id=1125

Description

Stockbrokers are known to overreact to rumours. You havebeen contracted to develop a method of spreading disinformation amongst thestockbrokers to give your employer the tactical edge in the stock market. Formaximum 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 thestructure of their contacts when starting a rumour. It takes a certain amountof time for a specific stockbroker to pass the rumour on to each of hiscolleagues. Your task will be to write a program that tells you whichstockbroker to choose as your starting point for the rumour, as well as thetime it will take for the rumour to spread throughout the stockbrokercommunity. This duration is measured as the time needed for the last person toreceive the information.

Input

Your program willinput data for different sets of stockbrokers. Each set starts with a line withthe number of stockbrokers. Following this is a line for each stockbroker whichcontains 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 ofeach stockbroker line is as follows: The line starts with the number ofcontacts (n), followed by n pairs of integers, one pair for each contact. Eachpair lists first a number referring to the contact (e.g. a '1' means personnumber one in the set), followed by the time in minutes taken to pass a messageto that person. There are no special punctuation symbols or spacing rules.

Each person is numbered 1 through to the number of stockbrokers. The time takento pass the message on will be between 1 and 10 minutes (inclusive), and thenumber of contacts will range between 0 and one less than the number ofstockbrokers. The number of stockbrokers will range from 1 to 100. The input isterminated by a set of stockbrokers containing 0 (zero) people.

Output

For each set of data, your program must output a singleline containing the person who results in the fastest message transmission, andhow long before the last person will receive any given message after you giveit to this person, measured in integer minutes.
It is possible that your program will receive a network of connections thatexcludes some persons, i.e. some people may be unreachable. If your programdetects 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 notnecessarily the same as the time taken to pass it from B to A, if such transmissionis possible at all.

Sample Input

3

2 2 4 3 5

2 1 2 3 6

2 1 2 2 2

5

3 4 4 2 8 5 3

1 5 8

4 1 6 4 10 2 7 5 2

0

2 2 5 1 5

0

Sample Output

3 2

3 10

Source

Southern African2001

题意:

这个题目到不会难,只是题意挺难理解的,大概讲的是消息在传送,第一行给出消息传送的人数n,接下来n行中的第一个数字表示第i个人可以传递以m个人(a,b)表示传递的编号和时间,问从那个人传送的时间会最快,时间是多少,同一个人传递给多个人时间只算一个最大的。

解题思路:

因为这个题目的数据量比较小,可以用Floyd-Warshall算法来做,这个算法求出每两个点之间的最小距离,在遍历一遍答案就可以出来了

代码:

#include <iostream>
#include<cstdio>
#include<cstring>
#define MAX 103
#define VALUE 0xffffff
using namespace std;

int g[MAX][MAX];
int d[MAX];
bool used[MAX];

int min(int x,int y)
{
	return x<y?x:y;
}
void Floyd(int n)
{
      int i,j,k;
	  for(k=1;k<=n;k++)
		  for(i=1;i<=n;i++)
			  for(j=1;j<=n;j++)
				  g[i][j]=min(g[i][j],g[i][k]+g[k][j]);//求出任意两点之间的最小值
}

int main()
{
    int ts;
    int i,j;
    int maxvalue,maxtime,t;
    while(true)
    {
        scanf("%d",&ts);
        if(ts==0)break;
       // memset(g,0,sizeof(g));
        for(i=1;i<=ts;i++)
            for(j=1;j<=ts;j++)
                  g[i][j]=VALUE;

        for(i=1;i<=ts;i++)
        {
            int n;
            scanf("%d",&n);
            g[i][i]=0;
            while(n--)
            {
                int  no,time;//时间和编号
                scanf("%d%d",&no,&time);
                g[i][no]=time;//建图
            }
        }
        Floyd(ts);
        maxtime=VALUE;
        for(i=1;i<=ts;i++)
        {
            maxvalue=0;
            for(j=1;j<=ts;j++)
            {
                if(g[i][j]>maxvalue)
                {//求出最长的边
                    maxvalue=g[i][j];
                }
            }
            if(maxvalue<maxtime)
            {
                maxtime=maxvalue;
                t=i;
            }
        }
        if(maxtime==VALUE)
        {
            printf("disjoint\n");
        }
        else
        {
            printf("%d %d\n",t,maxtime);
        }

    }
    return 0;
}


内容概要:本书《Deep Reinforcement Learning with Guaranteed Performance》探讨了基于李雅普诺夫方法的深度强化学习及其在非线性系统最优控制中的应用。书中提出了一种近似最优自适应控制方法,结合泰勒展开、神经网络、估计器设计及滑模控制思想,解决了不同场景下的跟踪控制问题。该方法不仅保证了性能指标的渐近收敛,还确保了跟踪误差的渐近收敛至零。此外,书中还涉及了执行器饱和、冗余解析等问题,并提出了新的冗余解析方法,验证了所提方法的有效性和优越性。 适合人群:研究生及以上学历的研究人员,特别是从事自适应/最优控制、机器人学和动态神经网络领域的学术界和工业界研究人员。 使用场景及目标:①研究非线性系统的最优控制问题,特别是在存在输入约束和系统动力学的情况下;②解决带有参数不确定性的线性和非线性系统的跟踪控制问题;③探索基于李雅普诺夫方法的深度强化学习在非线性系统控制中的应用;④设计和验证针对冗余机械臂的新型冗余解析方法。 其他说明:本书分为七章,每章内容相对独立,便于读者理解。书中不仅提供了理论分析,还通过实际应用(如欠驱动船舶、冗余机械臂)验证了所提方法的有效性。此外,作者鼓励读者通过仿真和实验进一步验证书中提出的理论和技术。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值