(poj)1502 MPI Maelstrom
题目链接:http://poj.org/problem?id=1502
Description BIT has recently taken delivery of their new supercomputer, a processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advisor, Jack Swigert, has asked her to benchmark the new system.
``Since the Apollo is a distributed shared memory machine, memory access and communication times are not uniform,'' Valentine told Swigert. ``Communication is fast between processors that share the same memory subsystem, but it is slower between processors that are not on the same subsystem. Communication between the Apollo and machines in our lab is slower yet.'' ``How is Apollo's port of the Message Passing Interface (MPI) working out?'' Swigert asked. ``Not so well,'' Valentine replied. ``To do a broadcast of a message from one processor to all the other n- processors, they just do a sequence of n- sends. That really serializes things and kills the performance.'' ``Is there anything you can do to fix that?'' ``Yes,'' smiled Valentine. ``There is. Once the first processor has sent the message to another, those two can then send messages to two other hosts at the same time. Then there will be four hosts that can send, and so on.'' ``Ah, so you can do the broadcast as a binary tree!'' ``Not really a binary tree -- there are some particular features of our network that we should exploit. The interface cards we have allow each processor to simultaneously send messages to any number of the other processors connected to it. However, the messages don't necessarily arrive at the destinations at the same time -- there is a communication cost involved. In general, we need to take into account the communication costs for each link in our network topologies and plan accordingly to minimize the total time required to do a broadcast.''
Input The input will describe the topology of a network connecting n processors. The first line of the input will be n, the number of processors, such that <= n <= . The rest of the input defines an adjacency matrix, A. The adjacency matrix is square and of size n x n. Each of its entries will be either an integer or the character x. The value of A(i,j) indicates the expense of sending a message directly from node i to node j. A value of x for A(i,j) indicates that a message cannot be sent directly from node i to node j. Note that for a node to send a message to itself does not require network communication, so A(i,i) = for <= i <= n. Also, you may assume that the network is undirected (messages can go in either direction with equal overhead), so that A(i,j) = A(j,i). Thus only the entries on the (strictly) lower triangular portion of A will be supplied. The input to your program will be the lower triangular section of A. That is, the second line of input will contain one entry, A(,). The next line will contain two entries, A(,) and A(,), and so on.
Output Your program should output the minimum communication time required to broadcast a message from the first processor to all the other processors.
Sample Input
Sample Output
题意:题意不好读懂,求什么从1号点到其他各点的最小距离的最大值
1--->2 35
1--->3 30
1--->4 20
1--->5 10 所以就是35…………
x表示两点之间不通
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <vector>
using namespace std;
#define N 1010
#define ll long long
#define INF 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof(a));
vector<vector<int> >Q;
int n,dis[N],vis[N],Map[N][N];
void init()
{
for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
Map[i][j]=i==j?:INF;
}
met(vis,);
}
void dij()
{
for(int i=; i<=n; i++)
{
dis[i]=INF;
}
dis[]=;
for(int i=; i<=n; i++)
{
int ans=INF,k=;
for(int j=; j<=n; j++)
if(!vis[j] && ans>=dis[j])
ans=dis[k=j];
vis[k]=;
for(int j=; j<=n; j++)
if(!vis[j] && dis[j]>dis[k]+Map[k][j])
dis[j]=dis[k]+Map[k][j];
}
}
int main()
{
char m[];
while(scanf("%d",&n)!=EOF)
{
init();
for(int i=; i<=n; i++)
{
for(int j=; j<i; j++)
{
scanf("%s",m);
if(m[]!='x')
Map[i][j]=Map[j][i]=atoi(m);
}
}
dij();
int ans=;
for(int i=; i<=n; i++)
{
ans=max(ans,dis[i]);
}
printf("%d\n",ans);
}
return ;
}
(poj)1502 MPI Maelstrom的更多相关文章
- 【POJ】1502 MPI Maelstrom
题目链接:http://poj.org/problem?id=1502 题意:一个处理器给n-1个处理器发送广播,问最短时间.广播时并发,也就是各个路径就大的一方.输入如果是x的话说明两个处理器不能相 ...
- POJ 1502 MPI Maelstrom / UVA 432 MPI Maelstrom / SCU 1068 MPI Maelstrom / UVALive 5398 MPI Maelstrom /ZOJ 1291 MPI Maelstrom (最短路径)
POJ 1502 MPI Maelstrom / UVA 432 MPI Maelstrom / SCU 1068 MPI Maelstrom / UVALive 5398 MPI Maelstrom ...
- POJ 1502 MPI Maelstrom(最短路)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4017 Accepted: 2412 Des ...
- POJ - 1502 MPI Maelstrom 路径传输Dij+sscanf(字符串转数字)
MPI Maelstrom BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odys ...
- POJ 1502 MPI Maelstrom
MPI Maelstrom Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) Total ...
- POJ 1502 MPI Maelstrom (最短路)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6044 Accepted: 3761 Des ...
- POJ 1502 MPI Maelstrom [最短路 Dijkstra]
传送门 MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5711 Accepted: 3552 ...
- POJ 1502 MPI Maelstrom(模板题——Floyd算法)
题目: BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distri ...
- POJ 1502 MPI Maelstrom (Dijkstra)
题目链接:http://poj.org/problem?id=1502 题意是给你n个点,然后是以下三角的形式输入i j以及权值,x就不算 #include <iostream> #inc ...
随机推荐
- ZOJ1111:Poker Hands(模拟题)
A poker deck contains 52 cards - each card has a suit which is one of clubs, diamonds, hearts, or sp ...
- 如何关闭log4j中配置的spring或者hibernate的日志信息
通常在建立一个web项目的时候,我们通常需要为其配置日志,以便了解启动过程中发生了什么,如果启动过程中发生了错误,则可以很方便的查看错误的信息,但是在项目部署到服务器上时,打印日志信息,需要耗费大量的 ...
- 找回丢失的SQL Server性能计数器
There was one time when I was delivering a Service using a tool that gathers performance data throug ...
- 产生不重复的随机数TGUID
uses ActiveX; procedure TForm1.BtnNewClick(Sender: TObject);var ID: TGUID; S: string;begin if CoC ...
- js操作json添加元素和数据的方法
function addServerUrlToJson() { var json_tem = [{"name":"a","value":1} ...
- Starling性能优化技巧十五则
Starling的性能优化要点 一.尽可能减少状态变更 如您所知,Starling使用Stage3D来渲染所有的可见对象.这就意味着所有的绘制都是GPU完成的. 现在,Starling可以一个接一个的 ...
- CentOS下yum安装mysql,jdk以及tomcat
首先说明,服务器是阿里云的,centos6.3_64位安全加固版.首先需要登陆进来,使用的是putty,因为最初的时候,Xshell登陆会被拒绝. 0. 创建个人文件夹 # 使用 yum 安装tomc ...
- C# 工厂模式示例
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 工厂模式 ...
- 如何使用VSTS做压力测试
1 前言 1.1 目的 本文档主要介绍如何在VSTS环境中进行LoadTest测试,给测试人员和初次使用者提供参考. 对该工具进行LoadTest测试的优劣进行简单的分析说明. 1.2 软件版本 本文 ...
- ArcGIS Desktop 与 Excel(转)
来自:http://blog.csdn.net/kikitamoon/article/details/19043161 微软 OFFICE 产品中,Excel是很强大,并且平民化的表格制作工具.Arc ...