题目这是用Dijsktra做的,稍加改动就好,1000ms。。好水。。#define _CRT_SECURE_NO_WARNINGS#include#include#include#includeusing namespace std;const int MAXN=1010; #define typec double const typec INF=0x3f3f3f3f;//防止后面溢出,这个不能太大 bool vis[MAXN]; typec cost[MAXN][MAXN];typec lowcost[MAXN];void Dijkstra(int n,int beg) { ... Read More
posted @ 2014-02-10 23:13 laiba2004 Views(421) Comments(0) Diggs(0) Edit
题目Dijsktra基础题,只是多了一个花费,稍稍变动处理就好#define _CRT_SECURE_NO_WARNINGS#include#include#include#includeusing namespace std;const int MAXN=1010; #define typec int const typec INF=0x3f3f3f3f;//防止后面溢出,这个不能太大 bool vis[MAXN]; typec cost[MAXN][MAXN],huafei[MAXN][MAXN];typec lowcost[MAXN],qihuafei[MAXN];void D... Read More
posted @ 2014-02-10 22:13 laiba2004 Views(195) Comments(0) Diggs(0) Edit
题目Dijkstra,正反两次最短路,求两次和最大的。#define _CRT_SECURE_NO_WARNINGS//这是找出最短路加最短路中最长的来回程//也就是正反两次最短路相加找最大的和#include#include#include#includeusing namespace std;const int MAXN=1010; #define typec int const typec INF=0x3f3f3f3f;//防止后面溢出,这个不能太大 bool vis[MAXN]; typec cost1[MAXN][MAXN],cost2[MAXN][MAXN];typec ... Read More
posted @ 2014-02-10 21:04 laiba2004 Views(244) Comments(0) Diggs(0) Edit
题目改动见下,请自行画图理解具体细节也请看下面的代码:这个花了300多ms#define _CRT_SECURE_NO_WARNINGS#include#include#include#includeusing namespace std;const int MAXN=1010; #define typec int const typec INF=200000000;//防止后面溢出,这个不能太大 bool vis[MAXN]; typec cost[MAXN][MAXN];typec lowcost[MAXN];void Dijkstra(int n,int beg) //连通图... Read More
posted @ 2014-02-10 16:06 laiba2004 Views(180) Comments(0) Diggs(0) Edit
题目这里的dijsktra的变种代码是我看着自己打的,终于把代码和做法思路联系上了,也就是理解了算法——看来手跟着画一遍真的有助于理解。#define _CRT_SECURE_NO_WARNINGS#include#include#include#includeusing namespace std;const int MAXN=210; #define typec double const typec INF=0x3f3f3f3f*1.0;//防止后面溢出,这个不能太大 bool vis[MAXN]; typec cost[MAXN][MAXN];typec lowcost[MAX... Read More
posted @ 2014-02-10 14:05 laiba2004 Views(270) Comments(0) Diggs(0) Edit