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 ...
随机推荐
- Unchecked runtime.lastError: The message port closed before a response was received.
这是由于某个 Chrome 扩展程序造成的. 打开 chrome://extensions/,逐一关闭排查.我这边是由于“迅雷下载支持”这个扩展引起的,将其关闭即可.
- js追加html元素
jquery追加html代码,添加元素 .append() //新增仲裁申请人 $("."+inputName).append("<div class=\" ...
- Java编程思想之十二 通过异常处理错误
Java的基本概念是结构不佳的代码不能运行余下的问题必须在运行期间解决,这就需要错误源能通过某种方式,把适当的信息传递给某个接收者--该接收者将知道如何正确处理这里问题. 12.1 概念 使用异常所带 ...
- 1-6docker数据共享与持久化
1.在 Docker 内部以及容器之间管理数据,在容器中管理数据主要有两种⽅式: 数据卷(Data Volumes) 挂载主机⽬录 (Bind mounts) 2.数据卷 数据卷 是⼀个可供⼀个或多个 ...
- 在myecplice中关联svn
1:下载插件 site-1.8.22 2:找到myecplic的安装目录 下的dropins 文件夹(例如:C:\Users\han\AppData\Local\MyEclipse Professio ...
- sts问题合集
背景:用来记录在使用sts过程中遇到的相关问题 Version 当前jdk版本号 of the JVM is not suitable for the this product.Version:1.8 ...
- 理解Spring中的IoC和DI
什么是IoC和DI IoC(Inversion of Control 控制反转):是一种面向对象编程中的一种设计原则,用来减低计算机代码之间的耦合度.其基本思想是:借助于"第三方" ...
- hread.interrupt()到底意味着什么
首先,一个线程不应该由其他线程来强制中断或停止,而是应该由线程自己自行停止. 所以,Thread.stop, Thread.suspend, Thread.resume 都已经被废弃了.而 Threa ...
- comment on exported function Perimeter should be of the form "Perimeter ..."go-lint
这个提示是检查代码注释格式有问题 正确方式:
- Akka-CQRS(13)- SSL/TLS for gRPC and HTTPS:自签名证书产生和使用
到现在,我们已经完成了POS平台和前端的网络集成.不过,还是那句话:平台系统的网络安全是至关重要的.前一篇博客里我们尝试实现了gRPC ssl/tls网络连接,但测试时用的证书如何产生始终没有搞清楚. ...