优先队列基础
来源:互联网 发布:游戏辅助编程 编辑:程序博客网 时间:2024/06/01 21:46
HDU1873
题目链接
题解:裸题,注意队列要清空,记下优先队列模板;
Code:
#include <cstdio>#include <queue>using namespace std;struct p{ int no; int level; friend bool operator <(p a,p b) { if(a.level==b.level)return a.no>b.no; return a.level<b.level; }};priority_queue<struct p> xq[5];int main(){ int n,a,b; char s[100]; while(scanf("%d",&n)!=EOF) { int k=0; for(int i=1;i<=3;i++) while(!xq[i].empty())xq[i].pop();//**** for(int i=1; i<=n; i++) { scanf(" %s %d",s,&a); if(s[0]=='I') { scanf("%d",&b); p x; x.level=b; x.no=(++k); xq[a].push(x); } else if(s[0]=='O') { if(xq[a].empty()) { printf("EMPTY\n"); } else { printf("%d\n",(xq[a].top()).no); xq[a].pop(); } } } } return 0;}
0 0
- 优先队列使用基础
- 优先队列基础
- 优先队列基础
- 基础queue优先队列
- STL 优先队列基础用法
- 堆(优先队列)基础
- C++语法基础--优先队列--priority_queue
- uva 136(Ugly Numbers, 优先队列基础)
- 基础练习 Huffuman树 (优先队列)
- [STL基础]栈、队列、优先队列之用法
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 25 python-opencv cv2.findcontours函数
- Problem I: 时间类的加、减法赋值运算
- 因特网协议栈中的层
- 又见jsp
- 【516】 Longest Palindromic Subsequence
- 优先队列基础
- Problem J: 时间类的流插入、提取和递增、递减运算
- bootstrap的tab选项卡
- kubelet 最佳配置
- Android一个应用多个图标的几种实现方式
- codeforces 300C 乘法逆元 (乘法逆元模为素数的模板)
- 了解 java 虚拟机基础知识
- uboot的Makefile
- 字符串字典树判重Linux内核代码风格