第八次ccf-交通规划

一直对dijkstra算法的写法存在盲区,参考自链接,自己编写

http://blog.csdn.net/aozil_yang/article/details/52841437

优先级队列用得很精髓,同时重载运算符函数后面需要加const,以前一直用的friend。。。

再次感谢大牛的博客,受教了

这个dijkstra加入模板,收益很大

#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=10000+10;
const int inf=0x3f3f3f;
struct edge{
	int f,to,w;
	edge(int a=0,int b=0,int c=0):f(a),to(b),w(c){
	}
};
struct node{
	int d,f;
	node(int a=0,int b=0):d(a),f(b){
	}
	bool operator < (const node& t) const{
		return d>t.d;
	}
};
int ans[maxn],k=0,visit[maxn],an[maxn];
map<int,vector<int> >g;
priority_queue<node> q;
vector<e
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值