poj1502 最短路】的更多相关文章

Time Limit: 1000MS Memory Limit: 10000K Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research ad…
题意:有n个处理器,给出n*n的邻接矩阵的一半,表示相互之间传输信息的花费(另一半与给出的一半对称,即双向都可传输),x表示不能传输,问从第一个处理器传输到所有处理器的最小花费总和是多少. 就是跑一遍最短路,然后求和…… 原来我以前做的最短路都这么水…… #include<stdio.h> #include<string.h> #include<vector> #include<algorithm> #include<queue> using n…
MPI Maelstrom Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7471   Accepted: 4550 Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchic…
//Accepted 320 KB 16 ms //有n个顶点,边权用A表示 //给出下三角矩阵,求从一号顶点出发到各点的最短路的最大值 #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <cmath> #include <algorithm> using namespace std; /** * This is a d…
题意:表面乍一看output是输出最小值,但仔细研究可以发现,这个最小值是从点1到所有点所花时间的最小值,其实是访问这些节点中的最大值,因为只有访问了最长时间的那个点才算访问了所有点.所以求最短路之后求最大值. #include <iostream> #include <cstring> #include <cstdio> using namespace std; + ; const int inf = 0x3f3f3f3f; int n, mp[maxn][maxn]…
#include<iostream> #include<cstdio> #include<string.h> #include<algorithm> using namespace std; #define INF 0x3f3f3f3f #define N 110 int ma[N][N]; int n; int dis[N]; bool vis[N]; void init() { for(int i=0;i<=n;i++) { for(int j=0…
MPI Maelstrom POJ-1502 这题是求最短路,但是因为一开始看错题目,导致我去使用prime算法求最小生成树 题意是指一台机器发出信息后,还可以向其他的机器发送信息,所以不能使用prime算法.尽管两者区别很小 #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<string> using namespace std;…
http://www.lydsy.com/JudgeOnline/problem.php?id=1001 思路:这应该算是经典的最大流求最小割吧.不过题目中n,m<=1000,用最大流会TLE,所以要利用平面图的一些性质. 这里讲一下平面图的对偶图性质. 在平面图中,所有边将图分成了n个平面.我们将平面标号,对于原图中的每条边,在与之相邻的两个平面间连一条边,最后得到的图就是原图的对偶图. 对偶图有如下性质: 1.对偶图的边数与原图相等. 2.对偶图中的每个环对应原图中的割. 于是可以在原图中的…
题意 一个联通图里给定若干个点,求他们到某点距离之和的最小值. 题解 枚举到的某点,然后优先队列优化的dijkstra求最短路,把给定的点到其的最短路加起来,更新最小值.复杂度是\(O(NElogE)\). 注意此题给的n是奶牛个数,p是牧场个数,p才是点的个数N,所以head.dis.vis要开到1000. 代码 /* USER:19flipp1 TASK:butter LANG:C++ */ #include<cstdio> #include<cstring> #include…
这是一道典型的最短路问题,直接用Dijkstra算法便可求解,主要是需要考虑输入的点是不是在已给出的地图中,具体看代码 #include<bits/stdc++.h> #define MAX 1000000 using namespace std; ];//记录每个点到起始点的距离 ][];//邻接矩阵 void init(){ ; i < ; i++){ ; j < ; j++)edge[i][j] = MAX;//邻接矩阵初始化为MAX } } int Dijkstra(int…