题干:

Message queue is the basic fundamental of windows system. For each process, the system maintains a message queue. If something happens to this process, such as mouse click, text change, the system will add a message to the queue. Meanwhile, the process will do a loop for getting message from the queue according to the priority value if it is not empty. Note that the less priority value means the higher priority. In this problem, you are asked to simulate the message queue for putting messages to and getting message from the message queue.

Input

There's only one test case in the input. Each line is a command, "GET" or "PUT", which means getting message or putting message. If the command is "PUT", there're one string means the message name and two integer means the parameter and priority followed by. There will be at most 60000 command. Note that one message can appear twice or more and if two messages have the same priority, the one comes first will be processed first.(i.e., FIFO for the same priority.) Process to the end-of-file.

Output

For each "GET" command, output the command getting from the message queue with the name and parameter in one line. If there's no message in the queue, output "EMPTY QUEUE!". There's no output for "PUT" command.

Sample Input

GET
PUT msg1 10 5
PUT msg2 10 4
GET
GET
GET

Sample Output

EMPTY QUEUE!
msg2 10
msg1 10
EMPTY QUEUE!

解题报告:

优先队列直接解。刚开始数组开太大了疯狂超内存。我还在node上加了个[MAX]  出现了这个报错 Segmentation Fault

AC代码:

#include<bits/stdc++.h>using namespace std;
const int MAX = 6e4 + 5;
struct Node {int id;char name[400];int k;//参数int vip;//Node(int id,char name[MAX],int k,int vip):id(id),name(name),k(k),vip(vip){}bool operator<(const Node b) const {if(vip!=b.vip) return vip>b.vip;return id>b.id;}
} node;
priority_queue <Node> pq;
char tmpname[MAX];
int main()
{char op[10];int cnt = 0;int k,v;while(~scanf("%s",op) ) {if(op[0] == 'G') {if(!pq.empty() ) {Node cur = pq.top();pq.pop();printf("%s %d\n",cur.name,cur.k);}else printf("EMPTY QUEUE!\n");}else {cnt++;scanf("%s%d%d",tmpname,&k,&v);Node tmp;tmp.id = cnt;tmp.k = k;tmp.vip = v;strcpy(tmp.name,tmpname);pq.push(tmp);}}return 0 ;
}

【ZOJ - 2724】【HDU - 1509】Windows Message Queue(优先队列)相关推荐

  1. HDOJ 1509 Windows Message Queue

    Windows Message Queue Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Othe ...

  2. Windows Message Queue(优先队列)

    欢迎参加--BestCoder周年纪念赛(高质量题目+多重奖励) Windows Message Queue Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  3. D - Windows Message Queue

    来源hdu1509 Message queue is the basic fundamental of windows system. For each process, the system mai ...

  4. ZOJ2724_Windows Message Queue(STL/优先队列)

    解题报告 题意: 看输入输出就非常明确. 思路: 优先队列. #include <algorithm> #include <iostream> #include <cst ...

  5. MSMQ(Microsoft Message Queue)介绍

    利用 MSMQ(Microsoft Message Queue),应用程序开发人员可以通过发送和接收消息方便地与应用程序进行快速可靠的通信.消息处理为您提供了有保障的消息传递和执行许多业务处理的可靠的 ...

  6. Microsoft Message Queue(MSMQ:微软消息队列)简介

    一.前言 最近在安装公司的一个产品时,接触到了MSMQ,在此对MSMQ做一个简单的介绍,以便各位能对它有一个快速.直观的认识.本文针对于Microsoft Message Queue,以下提到的消息队 ...

  7. Message、Handler、Message Queue、Looper之间的关系

    2019独角兽企业重金招聘Python工程师标准>>> 在单线程模型下,为了解决线程通信问题,Android设计了一个通信机制.Message Queue(消息队列), 线程间的通信 ...

  8. 远程调用服务(RPC)和消息(Message Queue)对比及其适用/不适用场合

    在阿里的平台技术部参与开发了Dubbo(远程调用服务)和Napoli(消息解决方案),又给网站应用支持这2个产品很长一段时间,了解了这2个产品的实现及应用对这两个产品的用法. 大部分情况下," ...

  9. Message Queue中的推与拉(转)

    Message Queue的设计和实现(7) http://mp.weixin.qq.com/s/zQdDBAHu1UgJJzxH2eCHgQ 数据发送中的推与拉. 当MQ要把数据给消费者的时候,就涉 ...

最新文章

  1. 《评人工智能如何走向新阶段》后记(再续21)
  2. kindeditor java 上传图片_java中KindEditor本地图片上传与上传失败问题
  3. ActiveMQ;RabbitMQ;ZeroMQ
  4. 【做题记录】[SCOI2009]围豆豆
  5. Swift泛型Protocol对比C#泛型Interface
  6. 前大厂员工谈中美企业区别,中企不用单元测试,仅靠QA检查代码?
  7. HDU4548 美素数【水题】
  8. Java:接口interface
  9. 苹果无线笔记本怎么连不上win服务器,苹果笔记本连不上无线_苹果笔记本连不上wifi...
  10. 分享选书原则,推荐几本书(附书评)
  11. 12306车站信息爬取(1)——实现站点所有信息的查询
  12. 架构-大数据架构-阿里
  13. 维基百科Wikipedia镜像网站列表
  14. QQ动态表情包如何制作, 制作软件哪个好
  15. 我的编程之路点滴记录(二)
  16. S7-1200中时钟功能设定和读写调用的具体方法
  17. Excel中如何进行快速单位换算
  18. SQL Compliance Manager Crack
  19. 20192132055 李欣桐第二次作业
  20. python日历gui_[代码全屏查看]-Python版的农历日历Calendar,功能简单

热门文章

  1. 835. Trie字符串统计
  2. 1-5 线性表元素的区间删除 (20 分)
  3. python数据可视化工具 pandas_Pandas数据可视化工具——Seaborn用法整理(下)
  4. npm环境安装linux,Node.js环境在linux上的部署教程
  5. 怎么在anaconda上安装python_我是如何用Anaconda来管理Python的
  6. 深入浅出MFC文档/视图架构之文档模板
  7. Sqlite3_prepare
  8. wince2秒快速启动TOC分析
  9. 搜索不包含关键词_亚马逊listing关键词优化
  10. linux怎么删除exe文件夹,ubuntu linux 批量删除文件