解题报告

题意:

看输入输出就非常明确。

思路:

优先队列。

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <map>using namespace std;
struct node {char m[100];int v,k;friend bool operator <(node a,node b) {return a.k>b.k;}
};
priority_queue<node>Q;
int main() {char str[100],str1[1000];int a,b;while(~scanf("%s",str)) {if(strcmp(str,"GET")==0) {if(Q.empty())printf("EMPTY QUEUE!\n");else {node a=Q.top();Q.pop();printf("%s %d\n",a.m,a.v);}} else if(strcmp(str,"PUT")==0) {scanf("%s%d%d",str1,&a,&b);node o;strcpy(o.m,str1);o.v=a;o.k=b;Q.push(o);}}return 0;
}

Windows Message Queue


Time Limit: 2 Seconds      Memory Limit: 65536 KB


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!

ZOJ2724_Windows Message Queue(STL/优先队列)相关推荐

  1. Windows Message Queue(优先队列)

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

  2. 【ZOJ - 2724】【HDU - 1509】Windows Message Queue(优先队列)

    题干: Message queue is the basic fundamental of windows system. For each process, the system maintains ...

  3. stl库的使用——队列queue和优先队列和优先队列小根堆(全家桶哎)

    其实实现队列蛮简单的,但敌不过人懒~ 于是stl库中就有了专门实现队列的函数#include<queue> 这里讲解下queue常用的几个操作 1.q.push(),向队列中插入元素 2. ...

  4. HDOJ 1509 Windows Message Queue

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

  5. stl优先队列定义可以吗_C ++ STL | 用户定义的优先级队列比较器

    stl优先队列定义>可以吗 In this article, we are going to see how to write your comparator function for prio ...

  6. D - Windows Message Queue

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

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

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

  8. MSMQ(Microsoft Message Queue)介绍

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

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

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

最新文章

  1. 手机时间插件 支持分钟多选_手机时间慢十几分钟,我穿越了吗?
  2. export 和export default不同的引入方式
  3. 【C语言学习趣事】_GCC源代码分析_2_assert.h
  4. coding怎么上传项目 mac_临近毕业,做过的项目怎么处理?
  5. DELL 控制卡做raid
  6. Gradient-Based Learning Applied to Document Recognition
  7. JavaWeb(二)Servlet和JSP简介
  8. 如何用vrml技术实现虚拟计算机组装实验,虚拟现实技术在计算机组装教学中的应用研究...
  9. NAT映射和代理服务器
  10. 2022 SPSSPRO杯A|B|C题思路分享【认证杯】
  11. JAVA系统蓝屏_Tomcat启动系统蓝屏
  12. sqlserver导入mdf文件
  13. 双绞线为什么要绞起来
  14. 箭头函数写法_JavaScript|箭头函数的用法
  15. Linux下Vim的常用命令操作大全
  16. “char”知多少。
  17. 样本方差为何除以n-1而不是n?
  18. IOS 个人证书的申请
  19. Executors工具类的相关方法
  20. 图文详解如何将书签bookmarks导回到chrome?

热门文章

  1. 神经网络训练中的Tricks之高效BP(反向传播算法)
  2. 7-9 N个数求和 (20 分)
  3. excel表中怎么插入visio_快速制作组织架构图,还在用Visio就out了,Excel简单三步搞定...
  4. 2019递归实现字符串的逆序存储(C++)
  5. mate40系统鸿蒙,Mate40领衔更新!鸿蒙系统首批升级机型名单:这些机型可坐等推送...
  6. Silverlight智能表单(3)之XML存储
  7. np.random的随机数函数
  8. Django运行项目时候出现DisallowedHost at / Invalid HTTP_HOST header:
  9. .NET DLL 保护措施详解(四)各操作系统运行情况
  10. 7,7显示选中的目标信息