noip 2015 普及 第四题 推销员 stl之priority_queue
来源:互联网 发布:淘宝付了定金已下架 编辑:程序博客网 时间:2024/06/17 17:04
转载:
http://blog.csdn.net/hongxdong/article/details/5559046
通过
收获:
(1)cout << q.top() << ' '; //queue当中是q.front();(2)vector的下标是从0开始的
(3)存入struct方式的priority_queue,方法如下
最好的方式:这个简洁!
struct Node{ int x,y; bool operator <(Node a) const { return y < a.y; } bool operator >(Node a) const { return y > a.y; }}; priority_queue<Node> A; //大根堆 priority_queue<Node, vector<Node>, greater<Node> > B; //小根堆
方式二:(cmp将结构体以val由大到小排列,组成大根堆)一般也用这个!
struct Node{int adj; int val;};struct cmp{bool operator()(Node a,Node b) { return a.val > b.val; }};priority_queue<Node,vector<Node>,cmp>Q;
0 0
- noip 2015 普及 第四题 推销员 stl之priority_queue
- [普及]NOIP 2015 推销员
- Codevs 5126 推销员 2015年NOIP全国联赛普及组
- 2015NOIP普及组第四题求和满分解法
- NOIP 2015 推销员
- 【noip普及组2016】第四题“魔法阵”
- 博弈论(noip普及组2010第四题 三国游戏)
- STL之priority_queue
- STL之priority_queue
- STL之priority_queue【转】
- STL之priority_queue
- STL之priority_queue
- STL之priority_queue
- STL之priority_queue
- STL之priority_queue实现
- STL之priority_queue
- STL之priority_queue
- STL之priority_queue
- spyder导入tensorflow包
- MFC学习(一):MFC的消息循环 --讲解到位
- POJ 1163 C++:The Triangle
- 朴素贝叶斯
- 队列
- noip 2015 普及 第四题 推销员 stl之priority_queue
- 一个非常易懂Git教程
- 59. Spiral Matrix II
- C语言数学函数ceil(), floor(), round()
- LeetCode179—Largest Number
- CSS简单代码
- 2016-12-14-记事本第一天
- Security solution for TO C TO B
- 【流媒体|从入门到出家】:流媒体协议—HTTP