题意  输入n  然后输入n个数  代表连接时每个站点自身的消耗   然后输入n*n的矩阵  第i行第j列的数代表第i个站点和第j个站点之间路上的花费  链接i,j两个节点的总花费为两站点自身花费加上路上的花费  求⑩这n个站点连通的最小总花费
又是裸的最小生成树  给点的就用prim咯
#include
#include
#include
using namespace std;
const...
                            
                            
                                分类:
Web程序   时间:
2014-10-24 16:35:09   
                                阅读次数:
360
                             
                    
                        
                            
                            
                                题意  有n个空间站  接下n行依次输入n个空间站的x,y,z坐标和半径  求连接所有空间站总共至少要修多长的桥
也是裸的最小生成树  注意距离不会小于0  就是两个空间站相交的时候
#include
#include
#include
#include
using namespace std;
const int N = 105, M = 10050;
int par[N], n, m;
d...
                            
                            
                                分类:
其他好文   时间:
2014-10-23 12:37:36   
                                阅读次数:
283
                             
                    
                        
                            
                            
                                题意  在n个村庄之间修路使所有村庄连通  其中有些路已经修好了  求至少还需要修多长路
还是裸的最小生成树  修好的边权值为0就行咯
#include
#include
#include
#include
using namespace std;
const int N = 105, M = 10050;
int par[N], n, m, mat[N][N];
int ans;
struc...
                            
                            
                                分类:
其他好文   时间:
2014-10-23 12:29:17   
                                阅读次数:
200
                             
                    
                        
                            
                            
                                题意  有n个村子  输入n  然后n-1行先输入村子的序号和与该村子相连的村子数t  后面依次输入t组s和tt s为村子序号 tt为与当前村子的距离  求链接所有村子的最短路径
还是裸的最小生成树咯
#include
#include
#include
using namespace std;
const int N=30,M=1000;
int par[N],n,m,ans;
struct...
                            
                            
                                分类:
其他好文   时间:
2014-10-23 10:45:21   
                                阅读次数:
174
                             
                    
                        
                            
                            
                                题意  给你n个点 m条边  求最小生成树的权
这是最裸的最小生成树了
#include
#include
#include
using namespace std;
const int N = 55, M = 3000;
int par[N], n, m, ans;
struct edge{int u, v, w;} e[M];
bool cmp(edge a, edge b){return...
                            
                            
                                分类:
Web程序   时间:
2014-10-23 10:43:45   
                                阅读次数:
229
                             
                    
                        
                            
                            
                                题意   求n个点m条边的图的连通子图中最长边的最小值
实际上就是求最小生成树中的最长边  因为最小生成树的最长边肯定是所有生成树中最长边最小的  那么就也变成了最小生成树了  不要被样例坑到了  样例并不是最佳方案  只是最长边与最小生成树的最长边相等  题目是特判  直接用最小生成树做就行
#include
#include
#include
using namespace std;
co...
                            
                            
                                分类:
Web程序   时间:
2014-10-22 12:57:48   
                                阅读次数:
249
                             
                    
                        
                            
                            
                                题意  给你农场的邻接矩阵  求连通所有农场的最小消耗
和上一题一样裸的最小生成树
#include
#include
#include
using namespace std;
const int N = 105, M = 10050;
int par[N], ans, n, m, t;
struct edge { int u, v, w;} e[M];
bool cmp(edge a, ...
                            
                            
                                分类:
Web程序   时间:
2014-10-22 11:02:47   
                                阅读次数:
203
                             
                    
                        
                            
                            
                                题意  给你n个点的坐标  每个点都可与其它n-1个点相连  求这n个点的最小生成树的权重
裸的最小生成树  直接kruskal咯
#include
#include
#include
#include
using namespace std;
const int N = 105, M = 10050;
double x[N], y[N], ans;
int n, m , par[N];
s...
                            
                            
                                分类:
其他好文   时间:
2014-10-22 10:05:06   
                                阅读次数:
203
                             
                    
                        
                            
                            
                                题意  在所有城市中找一个中心满足这个中心到所有公交站点距离的最大值最小 输出最小距离和满足最小距离编号最小的中心
最基础的BFS  对每个公交站点BFS  dis[i]表示编号为i的点到所有公交站点距离的最大值  bfs完所有站点后  dis[i]最小的点就是要求的点咯
#include
#include
#include
#include
using namespace std;
typ...
                            
                            
                                分类:
其他好文   时间:
2014-10-18 22:23:20   
                                阅读次数:
242
                             
                    
                        
                            
                            
                                题意 求迷宫中从a的位置到r的位置需要的最少时间  经过'.'方格需要1s  经过‘x’方格需要两秒  '#'表示墙
由于有1s和2s两种情况  需要在基础迷宫bfs上加些判断
令到达每个点的时间初始为无穷大  当从一个点到达该点用的时间比他本来的时间小时  更新这个点的时间并将这个点入队  扫描完全图就得到答案咯
#include
#include
#include
using names...
                            
                            
                                分类:
其他好文   时间:
2014-10-17 01:02:23   
                                阅读次数:
172