【POJ】1502 MPI Maelstrom
题目链接:http://poj.org/problem?id=1502
题意:一个处理器给n-1个处理器发送广播,问最短时间。广播时并发,也就是各个路径就大的一方。输入如果是x的话说明两个处理器不能相互通信。输入是矩阵的左三角。
题解:一个最短路的裸题吧。输入的时候注意一下字符的转换。floyd爆一遍之后再对每个路径找最大值即可。
代码:
- #include<cstdio>
- #include<cstdlib>
- #include<cstring>
- #include<iostream>
- using namespace std;
- const int N=;
- const int inf = 1e9;
- char s[];
- int n;
- int mp[N][N];
- void init(){
- for(int i = ; i <= n ;i++){
- for(int j = ; j <= n ;j++){
- if(i == j){
- mp[i][j] = ;
- }
- else{
- mp[i][j] = inf;
- }
- }
- }
- }
- void floyd(){
- for(int k = ; k <= n ; k++){
- for(int i = ; i <= n ;i++){
- for(int j = ; j <= n ;j++){
- mp[i][j] = min(mp[i][j],mp[i][k] + mp[k][j]);
- }
- }
- }
- int ans = -inf;
- for(int i = ; i <= n ;i++){
- if(mp[][i] != inf){
- ans = max(ans,mp[][i]);
- }
- }
- cout<<ans<<endl;
- }
- int main(){
- cin>>n;
- init();
- for(int i = ; i <= n ;i++){
- for(int j = ; j < i; j++){
- cin>>s;
- if(s[]!= 'x'){
- int num = atoi(s);
- mp[i][j] = mp[j][i] = num;
- }
- }
- }
- floyd();
- return ;
- }
【POJ】1502 MPI Maelstrom的更多相关文章
- (poj)1502 MPI Maelstrom
题目链接:http://poj.org/problem?id=1502 Description BIT has recently taken delivery of their processor A ...
- 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】1704 Georgia and Bob(Staircase Nim)
Description Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, ...
- 【POJ】1067 取石子游戏(博弈论)
Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后 ...
- POJ 1502 MPI Maelstrom(最短路)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4017 Accepted: 2412 Des ...
- 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 路径传输Dij+sscanf(字符串转数字)
MPI Maelstrom BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odys ...
- POJ 1502 MPI Maelstrom [最短路 Dijkstra]
传送门 MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5711 Accepted: 3552 ...
随机推荐
- 关于linux redhat及免费的问题
我想下载一个redhat的免费版,这个免费版是不是就不叫redhat了? 是Fedora吗? 不要推荐 红旗 以及其它的版本了,谢谢!!! 007struggle | 浏览 12141 次 发布于20 ...
- python re.findall 使用
python re.findall 使用 import re #\w 匹配字母数字及下划线 print(re.findall('\w','hello alan _god !@^&#^$^!*& ...
- jmter 5.1 中文
一.jmeter5.0下载解压后,默认的界面是英文版的,许多人觉得不方便,想要汉化,jmeter是不需要安装汉化包的,通过修改配置文件即可:1.找到jmeter解压后的文件夹,例如我是安装在D:\De ...
- Java方法中形参能否改变实参
前几天学习了java中的参数传递机制,总结了一些知识点: 1·参数类型为基本数据类型:整型:byte,short,int,long ,浮点型:float,double ,字符型:char ,布尔型:b ...
- 【二叉树】二叉树常用算法的C++实现
常见算法有: 1.求二叉树的最大深度 2.求二叉树的最小深度 3.二叉树的层次遍历 4.二叉树的前序遍历 5.二叉树的中序遍历 6.二叉树的后序遍历 7.求二叉树的节点个数 8.求二叉树的叶节点个数 ...
- vue组件通信之非父子组件通信
什么顺序不顺序的.. 先来说说非父子组件通信. 首先,我们先来了解下vue中的 1.$emit 触发当前实例上的事件,附加参数都会传给监听器回调. 2.$on 监听当前实例上的自定义事件.事件可以 ...
- Spring Boot Restful WebAPI集成 OAuth2
系统采用前后端分离的架构,采用OAuth2协议是很自然的事情. 下面开始实战,主要依赖以下两个组件: <dependency> <groupId>org.springframe ...
- 调用API接口,查询手机号码归属地(1)
使用https://www.juhe.cn/提供的接口,查询归属地 在官网注册key即可使用. 代码如下 #!/usr/bin/python # -*- coding: utf-8 -*- impor ...
- 内网渗透_win_socks代理_reGeorg+proxifier
遇到内网windows机器,如果想远程登陆,通常得通过代理,常用的nc.lcx 工具可满足要求. 如 lcx 示例: 两台机器上均上传lcx.exe 在 xp机器(公网)上执行 lcx.exe -li ...
- 完美编译街机模拟器MAME(Android版)基于MAME4all
重新编译MAME4droid源码 github上开源项目MAME4all可将MAME模拟器运行在iOS和Android上,还有一个比较有名的叫MAME4droid(MAME for android), ...