码迷,mamicode.com
首页 >  
搜索关键字:dijkstral + 优先队列    ( 2116个结果
最短路--dijkstra+优先队列优化模板
不写普通模板了,还是需要优先队列优化的昂 1 #include //基本需要的头文件 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 typedef pair pii; 8 const int I...
分类:其他好文   时间:2015-04-24 21:07:17    阅读次数:263
hdu 2828 Dogs
优先队列bfs,无难度,走x不用花时间,走“.”时间为1; #include #include #include #define maxn 1000+5 using namespace std; char mapp[maxn][maxn]; int visit[maxn][maxn]; int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}}; int n,m; in...
分类:其他好文   时间:2015-04-24 09:20:00    阅读次数:115
hdu 3152 Obstacle Course
bfs+优先队列,无难度 #include #include #include #define maxn 125+5 using namespace std; int n; int casee=1; int mapp[maxn][maxn]; int visit[maxn][maxn]; int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}}; struct stu ...
分类:其他好文   时间:2015-04-24 09:16:45    阅读次数:106
hdu 1503 Rank
哈夫曼树,优先队列 #include #include #include #include #define maxn 30+5 using namespace std; string ans; int sum[maxn]; priority_queue,greater >mapp; int main() { while(cin>>ans) { if(ans=="END"){break;}...
分类:其他好文   时间:2015-04-24 09:14:52    阅读次数:119
HDU 1702 ACboy needs your help again!(附加优先队列)
ACboy was kidnapped!! he miss his mother very much and is very scare now.You can't image how dark the room he was put into is, so poor :(.As a smart A...
分类:其他好文   时间:2015-04-23 23:16:22    阅读次数:168
【BZOJ】【4010】【HNOI2015】菜肴制作
拓扑排序 这题是要求N个点的一个拓扑序,且满足以下条件:编号1的位置尽可能靠前,在此基础上编号2的位置尽可能靠前…… 我看到这题的第一感觉:将拓扑排序用的队列改为优先队列,编号越小越早出来。 但是连样例都过不了= =因为这样做是【字典序最小】,并不一定满足题目的条件(看样例就知道了,这样其...
分类:其他好文   时间:2015-04-23 17:19:47    阅读次数:187
hdu 4006 The kth great number
优先队列,真是水的不行~ 保持队列里只有K个元素即可 #include #include using namespace std; priority_queue, greater >mapp; int n,k; string cmd; int main() { while(cin>>n>>k) { while(mapp.size()) mapp.pop(); while(n--) ...
分类:其他好文   时间:2015-04-22 22:21:58    阅读次数:105
hdu 1509 Windows Message Queue
考察优先队列,不过要注意优先队列的优先排序是不稳定排序,解决方法和自定义排序一样,再添加一个参数即可 #include #include using namespace std; string cmd; struct stu { string name; int p,lv,num; friend bool operator<(stu x,stu y) { if(x.lv==y.lv)...
分类:Windows程序   时间:2015-04-22 22:21:33    阅读次数:159
hdu 2527 Safe Or Unsafe
优先队列,注意队列开始时就只有一个数的特殊情况 #include #include using namespace std; int m; int rem[26]; priority_queue,greater >mapp; int main() { int t; cin>>t; while(t--) { int m; string ans; cin>>m>>ans; f...
分类:其他好文   时间:2015-04-22 22:19:39    阅读次数:188
nyoj754 黑心医生 结构体优先队列
对队列不懂的 可以看看我转的这篇文章STL整理。#include #include using namespace std; typedef struct { int rich,num; }node; queue s1; priority_queue,less >s2;//把less换成greater就是从小到大 int main() { node t,v; int n,m,x; w...
分类:其他好文   时间:2015-04-22 18:25:21    阅读次数:129
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!