kuangbin专题专题四 MPI Maelstrom POJ - 1502
题目链接:https://vjudge.net/problem/POJ-1502
dijkstra板子题,题目提供下三角情况,不包含正对角线,因为有题意都为0,处理好输入,就是一个很水的题。
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
using namespace std; typedef long long LL;
#define inf (1LL << 30) - 1
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--) const int N = ;
vector<pair<int,int> > G[N];
int val[N];
int vis[N];
int n; int fun(string& x){
int sum = ; rep__(i,,(int)x.length()) sum = sum * + (x[i] - ''); return sum;
} void input(){ string w;
rep(i,,n){
rep__(j,,i){
cin >> w; if(w[] == 'x') continue;
int W = fun(w);
G[i].push_back(make_pair(j,W));
G[j].push_back(make_pair(i,W));
}
}
} int dijkstra(){ if(n == ) return ;
val[] = ;
rep(i,,n) val[i] = inf; rep__(i,,(int)G[].size()) val[G[][i].first] = G[][i].second;
vis[] = true; rep(i,,n){ int x = -;
int v = inf; rep(j,,n){
if(!vis[j] && v > val[j]) v = val[x = j];
} if(x == -) continue;
vis[x] = true; rep__(o,,(int)G[x].size()){
int v = G[x][o].first;
int w = G[x][o].second;
if(!vis[v] && val[v] > val[x] + w)
val[v] = val[x] + w;
}
} int ans = ;
rep(i,,n) ans = max(ans, val[i]); return ans;
} int main(){ ios::sync_with_stdio(false);
cin.tie(); cin >> n;
input();
cout << dijkstra() << endl; getchar();getchar();
return ;
}
kuangbin专题专题四 MPI Maelstrom POJ - 1502的更多相关文章
- MPI Maelstrom POJ - 1502 floyd
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> usin ...
- 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 ...
- 「kuangbin带你飞」专题十四 数论基础
layout: post title: 「kuangbin带你飞」专题十四 数论基础 author: "luowentaoaa" catalog: true tags: mathj ...
- 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 ...
- POJ 1502:MPI Maelstrom Dijkstra模板题
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6499 Accepted: 4036 Des ...
随机推荐
- readfile,read,createReadStream函数
这三个函数使用前都需要引入fs模块(var fs= require(“fs”) ) readfile:读取文件内容的异步函数,readFile方法是将要读取的文件内容完整读入缓存区,再从该缓存区中读取 ...
- Spring Security教程之session管理(十一)
1.1 检测session超时 1.2 concurrency-control 1.3 session 固定攻击保护 Spring Security通过http元素下的子元素s ...
- FPGA硬件加速
FPGA市场占有率最高的两大公司Xilinx和Altera. 查找表(Look-Up-Table)简称为LUT,LUT本质上就是一个RAM.目前FPGA中多使用4输入的LUT,所以每一个LUT可以看成 ...
- Gamma阶段第八次scrum meeting
每日任务内容 队员 昨日完成任务 明日要完成的任务 张圆宁 #91 用户体验与优化https://github.com/rRetr0Git/rateMyCourse/issues/91(持续完成) # ...
- centos 6.9 安装docker
1.查看系统具体版本 yum install lsb -y lsb_release -a 2.安装yum源 yum -y install http://dl.fedoraproject.org/pub ...
- 【RabbitMQ学习之一】RabbitMQ入门
环境 win7 rabbitmq-server-3.7.17 Erlang 22.1 RabbitMQ使用Erlang语言开发消息中间件.RabbitMQ基于AMQP(高级消息队列协议)协议,更适合业 ...
- nginx负载均衡+keepalived高可用
nginx负载均衡+keepalived高可用 环境准备 192.168.88.111:nginx + keepalived MASTER 192.168.88.112:nginx + keepa ...
- 高度随每片内容的高度变化的swiper react-native-unfixed-height-swiper
高度随每片内容的高度变化的swiper react-native-unfixed-height-swiper 内容可以文本 图片 视频 本例里面的为文本 使用方式1. npm i react-n ...
- 【题解】选数字 [51nod1354]
[题解]选数字 [51nod1354] 传送门:选数字 \([51nod1354]\) [题目描述] 共 \(T\) 组测试点,每一组给定一个长度为 \(n\) 的序列和一个整数 \(K\),找出有多 ...
- kafka broker Leader -1引起spark Streaming不能消费的故障解决方法
一.问题描述:Kafka生产集群中有一台机器cdh-003由于物理故障原因挂掉了,并且系统起不来了,使得线上的spark Streaming实时任务不能正常消费,重启实时任务都不行.查看kafka t ...