优先队列
文章平均质量分 71
普通网友
这个作者很懒,什么都没留下…
展开
-
无题
无题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2587 Accepted Submission(s): 1122 Problem Description 就要复试了,外地的考生都要在学校附近住宾馆了。原创 2014-01-22 17:08:50 · 375 阅读 · 0 评论 -
hdu 4006 The kth great number
#include #include using namespace std; struct node { int num; friend bool operator<(node n1,node n2) { return n1.num>n2.num; } }; int main() { node now,next; priority_q原创 2014-01-24 11:21:33 · 342 阅读 · 0 评论 -
最小值优先
#include #include #include #include using namespace std; struct node { bool operator()(int a,int b) { return a>b; } }; int main() { int a[100]; int n; while(cin>>n)原创 2014-02-11 09:07:15 · 461 阅读 · 0 评论 -
最大值优先
#include #include #include #include using namespace std; struct node { int x; friend bool operator>(node n1,node n2) { return n1.x<n2.x; } }; int main() { int n; no原创 2014-02-11 09:29:03 · 367 阅读 · 0 评论 -
A Stack or A Queue?
第一行:数字t,表示测试数;第二行:数字n,表示下面两行每行有n个数;第三四行:每行输入n个数;判断是栈还是队列。栈是先进后出,队列是先进先出。Sample Input4 3 1 2 3 3 2 1 3 1 2 3 1 2 3 3 1 2 1 1 2 1 3 1 2 3 2 3 1 Sample Output stack queue both neithe原创 2014-02-11 10:43:25 · 483 阅读 · 0 评论 -
优先队列讲解
优先队列用法 在优先队列中,优先级高的元素先出队列。 标准库默认使用元素类型的 优先队列的第一种用法,也是最常用的用法: priority_queueint> qi; 通过 故示例1中输出结果为:9 6 5 3 2 第二种方法: 在示例1中,如果我们要把元素从小到大输出怎么办呢? 这时我们可以传入一个比较函数,使用functional.h函数对象作为比较函数。 pr转载 2014-02-13 11:30:56 · 454 阅读 · 0 评论