POJ 1502 MPI MaeIstrom ( 裸最短路 || atoi系统函数 )
题意 : 给出 N 个点,各个点之间的路径长度用给出的下三角矩阵表示,上上角矩阵和下三角矩阵是一样的,主对角线的元素都是 0 代表自己到达自己不用花费,现在问你从 1 到 N 的最短路,矩阵的 x 代表点间无法互相到达
分析 : 最短路模板…… 就是在输入的时候需要将字符串变成整数、自己写也可以,也可以使用 atoi(char *)函数,其作用是将字符串数组变成整数,复杂度为 O(n)
#include<bits/stdc++.h>
using namespace std;
;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> HeapNode;
struct EDGE{ int v, nxt, w; };
int Head[maxn], Dis[maxn];
EDGE Edge[maxn*maxn];
int N, cnt;
inline void init()
{
; i<=N; i++)
Head[i]=-, Dis[i]=INF;
cnt = ;
}
inline void AddEdge(int from, int to, int weight)
{
Edge[cnt].v = to;
Edge[cnt].w = weight;
Edge[cnt].nxt = Head[from];
Head[from] = cnt++;
}
int Dijkstra(int st)
{
priority_queue< HeapNode, vector<HeapNode>, greater<HeapNode> > Heap;
Dis[st] = ;
Heap.push(make_pair(, st));
while(!Heap.empty()){
pair<int, int> T = Heap.top(); Heap.pop();
if(T.first != Dis[T.second]) continue;
; i=Edge[i].nxt){
int Eiv = Edge[i].v;
if(Dis[Eiv] > Dis[T.second] + Edge[i].w){
Dis[Eiv] = Dis[T.second] + Edge[i].w;
Heap.push(make_pair(Dis[Eiv], Eiv));
}
}
}
;
; i<=N; i++)
ret = max(ret, Dis[i]);
return ret;
}
];
int main(void)
{
while(~scanf("%d", &N)){
init();
; i<=N; i++){
; j<i; j++){
scanf("%s", Digit);
] != 'x'){
int weight = atoi(Digit);
AddEdge(i, j, weight);
AddEdge(j, i, weight);
}
}
}
printf());
}
;
}
POJ 1502 MPI MaeIstrom ( 裸最短路 || atoi系统函数 )的更多相关文章
- POJ 1502 MPI Maelstrom(最短路)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4017 Accepted: 2412 Des ...
- 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: 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
MPI Maelstrom Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) Total ...
- POJ 1502 MPI Maelstrom (Dijkstra)
题目链接:http://poj.org/problem?id=1502 题意是给你n个点,然后是以下三角的形式输入i j以及权值,x就不算 #include <iostream> #inc ...
- (简单) POJ 1502 MPI Maelstrom,Dijkstra。
Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odysse ...
- POJ 1502 MPI Maelstrom(模板题——Floyd算法)
题目: BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distri ...
- POJ - 1502 MPI Maelstrom 路径传输Dij+sscanf(字符串转数字)
MPI Maelstrom BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odys ...
随机推荐
- Swiper轮播隐藏再显示后不动
公告用Swiper轮播方式,在某些不需要显示公告的页面进行隐藏,在需要展示公告的页面进行显示时候,公告不能正常轮播,在条件里加入重新设置轮播方法等网上的一些方法仍然不行,最后解决方法: this.my ...
- 类LinkedHashSet
/* * LinkedHashSet底层数据结构由哈希表和链表组成 * 哈希表保证元素的唯一性 * 链表保证元素有序(存储和取出是一致的) * */ import java.util.LinkedHa ...
- Java ——Character 类
本节重点思维导图 Character 类用于对单个字符进行操作. Character 类在对象中包装一个基本类型 char 的值 char ch = 'a'; // Unicode 字符表示形式 ch ...
- 3 Vue.js基础
Vue中的过滤器.钩子函数.指令.字符串填充.以及部分方法使用的案例(操作表单) <!DOCTYPE html> <html lang="en"> < ...
- 设置IIS的gzip
如果服务器iis 中没有配置动态压缩的话,在性能中选项中配置. 设置成功之后:
- powerdisigner
- [Python3] 020 借函数,谈一谈变量的作用域
目录 1. 概述 2. 分类 3. 变量的作用范围 少废话,上例子 4. 将局部变量提升为全局变量 少废话,上例子 5. 内建函数 globals() 与 locals() 少废话,上例子 6. 邪恶 ...
- 高性能JavaScript模板引擎实现原理详解
这篇文章主要介绍了JavaScript模板引擎实现原理详解,本文着重讲解artTemplate模板的实现原理,它采用预编译方式让性能有了质的飞跃,是其它知名模板引擎的25.32 倍,需要的朋友可以参考 ...
- 通过总线机制实现自动刷新客户端配置(Consul,Spring Cloud Config,Spring Cloud Bus)
通过总线机制实现自动刷新客户端配置 方案示意图 利用Git服务的webhook通知功能,在每次更新配置之后,Git服务器会用POST方式调用配置中心的/actuator/bus-refresh接口,配 ...
- 移动端自动化测试之Appium的工作原理学习
Appium 简介 参考官网文档说明:http://appium.io/docs/en/about-appium/intro/ Appium官方文档上介绍,Appium 是一个自动化测试的开源工具,支 ...