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 ...
随机推荐
- JavaScript随机数类型
1.Math.random(); 结果为0-1间的一个随机数(包括0,不包括1) 2.Math.floor(num); 参数num为一个数值,函数结果为num的整数部分. 3.Math.round(n ...
- 中位数的和_KEY
中位数的和 (number.pas/c/cpp) [题目描述] flower 有 N-1 个朋友,他们要一起玩一个游戏:首先确定三个非负整数 a,b,c,然后每个人依次在纸上写一个数,设第 i 个人写 ...
- oracle pl/sql 变量
一.变量介绍在编写pl/sql程序时,可以定义变量和常量:在pl/sql程序中包括有:1).标量类型(scalar)2).复合类型(composite) --用于操作单条记录3).参照类型(refer ...
- 点击截图功能 js canvas
使用:html2canvas实现浏览器截图 <html> <head> <meta name="layout" content="main& ...
- 巧用Mono.Cecil反射加载类型和方法信息
最近在做服务的细粒度治理,统一管理所有服务的方法.参数.返回值信息.方便后续的各个模块之间的对接和协作. 目前系统中所有的服务,管理到接口契约粒度,即服务接口声明和服务接口实现.要做服务的细粒度治理: ...
- Kafka快速上手(2017.9官方翻译)
为了帮助国人更好了解.上手kafka,特意翻译.修改了个文档.官方Wiki : http://kafka.apache.org/quickstart 快速开始 本教程假定您正在开始新鲜,并且没有现有的 ...
- Linux入门之常用命令(2)
(三) 链接文件 ln [-s] [源文件] [目标文件] -s表示符号链接 没有则是硬链接 硬链接是一个独立文件 (相当于一个副本) 符号链接是一个链接文件(相当于一个快捷方式) 但是修 ...
- Rectangles hdu2461容斥定理
Rectangles Time Limit: 5000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- 最长回文 hdu3068(神代码)
最长回文 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 使用JS动态修改网页body的背景色
大部分网页默认的背景色为白色,个人感觉比较刺眼,于是写了个JS的脚本去改变body部分的背景色,代码如下: // ==UserScript== // @name ChangeBackgroundCol ...