Windows Message Queue
Windows Message Queue |
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) |
Total Submission(s): 85 Accepted Submission(s): 53 |
Problem Description
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 |
Sample Output
EMPTY QUEUE! |
Author
ZHOU, Ran
|
Source
Zhejiang University Local Contest 2006, Preliminary
|
Recommend
linle
|
/*
题意:简单的模拟两个操作:GET获取优先级最高的,PUT压进栈东西 初步思路:优先队列,搞一下,本来想偷一下懒。把以前写的代码贴上,结果死活不对。
*/
#include<bits/stdc++.h>
using namespace std;
struct node{
string name;
int val;
int Rank;
int time;
node(){}
node(string a,int b,int c,int d){
name=a;
val=b;
Rank=c;
time=d;
}
bool operator < (const node &other) const{
if(Rank==other.Rank)
return time>other.time;
return Rank>other.Rank;
}
};
priority_queue<node> Message;
string op;
string name;
int times=;
int val,Rank;
void init(){
times=;
while(!Message.empty()) Message.pop();
}
int main(){
// freopen("in.txt","r",stdin);
init();
while(cin>>op){
if(op=="GET"){
if(Message.empty()) puts("EMPTY QUEUE!");
else{
cout<<Message.top().name<<" "<<Message.top().val<<endl;
Message.pop();
}
}else{
cin>>name>>val>>Rank;
Message.push(node(name,val,Rank,times++));
}
}
return ;
}
Windows Message Queue的更多相关文章
- hdu 1509 Windows Message Queue
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1509 Windows Message Queue Description Message queue ...
- hdoj 1509 Windows Message Queue【优先队列】
Windows Message Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- Windows Message Queue(优先队列)
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Windows Message Queue Time Limit: 2000/1000 MS (Java/Others) Mem ...
- zoj 2724 Windows Message Queue
Windows Message Queue Time Limit: 2 Seconds Memory Limit: 65536 KB Message queue is the basic f ...
- hdu 1509 Windows Message Queue (优先队列)
Windows Message QueueTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDU 1509 Windows Message Queue(队列)
题目链接 Problem Description Message queue is the basic fundamental of windows system. For each process, ...
- D - Windows Message Queue
来源hdu1509 Message queue is the basic fundamental of windows system. For each process, the system mai ...
- H - Windows Message Queue
Message queue is the basic fundamental of windows system. For each process, the system maintains a m ...
- zoj 2724 Windows Message Queue(使用priority_queue容器模拟消息队列)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2724 题目描述: Message queue is the b ...
随机推荐
- 内核对象 windows操作系统
问题: 什么是内核对象? 答:内核对象实际上时由内核分配的一块内存,而且只能由内核来访问.它时一个数据结构,成员包含有关于该对象的信息.一些成员对于所有对象类型都是一样的,比如对象名称.安全描述.使用 ...
- RG_5
必须发博纪念经过昨天的开车, 作业本终于做完啦!!! 可以认真的刷题了.
- [Node.js] 2、利用node-git-server快速搭建git服务器
本文用到了node-git-server 1.检测本地git版本 该包的使用需要机器上本来就安装git,且git的版本大于等于2.7: ╭─root@lt /home/workspace ╰─# gi ...
- 【2016美团】浏览器和服务器在基于https进行请求链接到数据传输过程中,用到了如下哪些技术
A.非对称加密技术 B.对称加密技术 C.散列(哈希)算法 D.数字证书 答案:ABCD HTTPS在传输数据之前需要客户端(浏览器)与服务端(网站)之间进行一次握手,在握手过程中将确立双方加密传输数 ...
- python 发送邮件,未完
def send_mail(): try: print "send mail..." # handle = smtplib.SMTP('smtp.163.com', 25) # h ...
- ora-01440:要减小精度或标度,则要修改的列必须为空
--由于业务需求变更,需要对oracle数据库productinfo表的productPrcie结构进行修改.修改表结构,必须是在表空的情况下才可以修改表结构.具体操作步骤: --1.查看produc ...
- WPF通过代码动态的加载样式
tabitem.SetResourceReference(TabItem.StyleProperty, "mainTabItemStyle"); tabitem.Content = ...
- #云栖大会# 移动安全专场——APP渠道推广作弊攻防那些事儿(演讲速记)
导语: 如今,移动互联网浪潮进入白热化竞争态势,APP渠道传播成为很多企业常用的推广方式,APP推广费用也在水涨船高,从PC时代的一个装机0.5元到1元不等,到移动互联网时代的5元,甚至几十元,但为什 ...
- UWP 手绘视频创作工具技术分享系列 - 位图的绘制
前面我们针对 SVG 的解析和绘制做了介绍,SVG 是图片的一种形式,而另一种很重要的图片是:位图,包括 png.jpeg.bmp 等格式.位图的基本规则是,组成的基本元素是像素点,由宽度 * 高度个 ...
- YYHS-string(线段树)
题解 这道题给你两个操作,一个升序,一个降序 我们可以观察到这个字符串都是由小写字母组成的,只有26个字符,所以我们开一个26个字符的线段树 每次查询的时候找到这个区间内'a'到'z'的数量,再判断一 ...