Description

  BIT has recently taken delivery of their new supercomputer, a 32 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-1 processors, they
just do a sequence of n-1 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.''

 
  就是求最短路里面最大的那个。。。
 
代码如下:
#include<iostream>
#include<cstring>
#include<cstdio> using namespace std; const int MaxN=;
const int INF=10e8; bool vis[MaxN]; void Dijkstra(int cost[][MaxN],int lowcost[],int n,int start)
{
for(int i=;i<=n;++i)
{
vis[i]=;
lowcost[i]=INF;
}
lowcost[start]=; for(int j=;j<=n;++j)
{
int k=-;
int minn=INF; for(int i=;i<=n;++i)
if(!vis[i] && lowcost[i]<minn)
{
minn=lowcost[i];
k=i;
} if(k==-)
break; vis[k]=; for(int i=;i<=n;++i)
if(!vis[i])
lowcost[i]=min(lowcost[k]+cost[k][i],lowcost[i]);
}
} int ans[MaxN];
int map1[MaxN][MaxN]; int main()
{
int n;
int maxn;
char c[]; while(~scanf("%d",&n))
{
for(int i=;i<=n;++i)
for(int j=;j<=i;++j)
if(i==j)
map1[i][j]=;
else
{
scanf("%s",c); if(c[]!='x')
sscanf(c,"%d",&map1[i][j]);
else
map1[i][j]=INF; map1[j][i]=map1[i][j];
} Dijkstra(map1,ans,n,); maxn=-; for(int i=;i<=n;++i)
if(ans[i]>maxn)
maxn=ans[i]; cout<<maxn<<endl;
} return ;
}

(简单) POJ 1502 MPI Maelstrom,Dijkstra。的更多相关文章

  1. POJ 1502 MPI Maelstrom (Dijkstra)

    题目链接:http://poj.org/problem?id=1502 题意是给你n个点,然后是以下三角的形式输入i j以及权值,x就不算 #include <iostream> #inc ...

  2. 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 ...

  3. POJ 1502 MPI Maelstrom [最短路 Dijkstra]

    传送门 MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5711   Accepted: 3552 ...

  4. POJ 1502 MPI Maelstrom

    MPI Maelstrom Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) Total ...

  5. POJ 1502 MPI Maelstrom(最短路)

    MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4017   Accepted: 2412 Des ...

  6. POJ 1502 MPI Maelstrom (最短路)

    MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6044   Accepted: 3761 Des ...

  7. POJ - 1502 MPI Maelstrom 路径传输Dij+sscanf(字符串转数字)

    MPI Maelstrom BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odys ...

  8. POJ 1502 MPI Maelstrom( Spfa, Floyd, Dijkstra)

    题目大意: 给你 1到n ,  n个计算机进行数据传输, 问从1为起点传输到所有点的最短时间是多少, 其实就是算 1 到所有点的时间中最长的那个点. 然后是数据 给你一个n 代表有n个点, 然后给你一 ...

  9. POJ 1502 MPI Maelstrom(模板题——Floyd算法)

    题目: BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distri ...

随机推荐

  1. Objective-C语法之NSMutableString字符串的那些事儿

     Objective-C语法之字符串那些事         NSMutableString 类 继承NSString类,那么NSString 提供的方法在NSMutableString中基本都可以使用 ...

  2. Java-Spring MVC如何返回一个非JSP文件名字的地址

    return new ModelAndView("redirect:/bizitem/goEditItem.do?item_id="+item_id+"&msg= ...

  3. 字符函数库 cctype

    <cctype> (ctype.h) Character handling functions This header declares a set of functions to cla ...

  4. Android抽屉(SlidingDrawer --类似android通知栏下拉效果)

    Android抽屉(SlidingDrawer)的实现发 - 红黑联盟http://www.2cto.com/kf/201301/182507.html 可动态布局的Android抽屉之基础http: ...

  5. 异步加载AsyncTask

    private void huodeshuju() {        new AsyncTask<String, Void, String>() {            @Overrid ...

  6. linux shell 远程执行命令

    经常要部署多台服务器上面的应用,如果一个个机器的登录太麻烦. 所有就想到编写一个脚本来部署不同的服务器 前提条件: 配置ssh免登陆 如果不会的请参加我的另外一篇文章 http://blog.csdn ...

  7. PAT (Advanced Level) 1097. Deduplication on a Linked List (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  8. ajax请求dotnet webservice格式

    $.ajax({ type: "post", url: "your_webservice.asmx/you_method", contentType: &quo ...

  9. Nginx代理外网映射

    外网映射内网端口8080, 外网访问使用端口8379: nginx监听8080和80端口 #user nobody; worker_processes ; #error_log logs/error. ...

  10. discuz 添加板块失败解决办法

    最近把服务器环境升了下级,发现discuz后台添加栏目添加不了了,数据库没变,源代码没变,就突然添加不了了.刚开始添加1个板块成功了,再添加就怎么也添不进去了.只是页面刷新了一下,啥提示没有. 经过一 ...