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 ...
随机推荐
- 【BigData】Java基础_ArrayList的使用
ArrayList概述 ArrayList底层使用的是数组.是List的可变数组实现,这里的可变是针对List而言,而不是底层数组. 数组有自身的特点,不变性,一旦数组被初始化,那么其长度就固定了,不 ...
- prometheus、node_exporter、cAdvisor常用参数
本节将介绍一下我在使用过程中用到的promethues.node_exporter.cAdvisor的常用参数,做一个总结 一.prometheus prometheus分为容器安装和二进制文件安装, ...
- Leetcode 初刷(1)
1.给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. 你可以假设每种输入只会对应一个答案.但是,你不能重复利用这个数组中同样 ...
- 【原】无脑操作:Webstorm集成Git/Github
Webstorm作为前端开发的主流工具,对Git及Github可以非常简便的集成. 1.开发环境:(如何安装就不说了) ① Webstorm 2018 ② git version 2.20.1 ③ G ...
- 停止IIS服务
1 第一步 停止 World Wide Web Publishing Service 这个是W3C服务 2 第二部 停止 IIS Admin Service 这个IIS元数据管理服务
- Maven 教程(6)— Maven之pom.xml文件简单说明
原文地址:https://blog.csdn.net/liupeifeng3514/article/details/79543963 通过前面几部分知识,我们对maven已经有了初步的印象,就像Mak ...
- Spring JDBC最佳实践(3)
原文地址:https://my.oschina.net/u/218421/blog/38598 spring jdbc包提供了JdbcTemplate和它的两个兄弟SimpleJdbcTemplate ...
- Alpha冲刺——测试篇
课程信息 课程 软件工程1916|W(福州大学) 团队名称 修!咻咻! 作业要求 项目Alpha冲刺 团队目标 切实可行的计算机协会维修预约平台 团队信息 队员学号 队员姓名 个人博客地址 备注 22 ...
- [原创]Ladon5.7大型内网渗透综合漏洞扫描器
Ladon LadonGUI Cobalt Strike PowerLadon PythonLadon LinuxLadon 使用说明 ID 主题 URL 1 Ladon文档主页 https://gi ...
- 爬虫基础 之 urllib
一.urllib 1. 访问 urllib.request.urlopen() 参数: url:需要爬取的URL地址 timeout:设置等待时间,指定时间内未得到相应时抛出异常 # 导入模块 imp ...