Windows Message Queue

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4395    Accepted Submission(s): 1745

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
PUT msg1 10 5
PUT msg2 10 4
GET
GET
GET

Sample Output
EMPTY QUEUE!
msg2 10
msg1 10
EMPTY QUEUE!
 
这个题的大意是:输入GET就输出输入的数据,如果没数据就输出EMPTY QUEUE!
每个数据都有优先级,优先级越小越先输出!优先级相同时,谁先输入谁就先输出!
 
 
分析:用优先级数列来做
 
 
 
 
 
 
 
 #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#define max 60010
using namespace std;
struct as
{
char a[];
int b,c,d;
bool friend operator <(as x,as y)
{
if(x.c!=y.c)
return x.c>y.c;//如果优先级不相等,从小到大排
else
return x.d>y.d;//如果优先级相等,按输入先后顺序排
}
}aa[max];
priority_queue<struct as>q;
char str[];
int main()
{
int i=,j,k,n;
while(scanf("%s",str)!=EOF)
{
getchar();
if(strcmp(str,"PUT")==)
{
scanf("%s",aa[i].a);
scanf("%d %d",&aa[i].b,&aa[i].c);//输入参数和优先级
aa[i].d=i;//记录输入的先后次序,以便aa[i].y相等时比较
q.push(aa[i]);
i++;
}
else if(strcmp(str,"GET")==)
{
if(q.empty())
printf("EMPTY QUEUE!\n");
else
{
struct as er=q.top();
q.pop();
printf("%s %d\n",er.a,er.b);
}
}
}
return ;
}

Windows Message Queue--hdu1509的更多相关文章

  1. hdu 1509 Windows Message Queue

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1509 Windows Message Queue Description Message queue ...

  2. hdoj 1509 Windows Message Queue【优先队列】

    Windows Message Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  3. Windows Message Queue(优先队列)

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

  4. Windows Message Queue

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

  5. zoj 2724 Windows Message Queue

    Windows Message Queue Time Limit: 2 Seconds      Memory Limit: 65536 KB Message queue is the basic f ...

  6. hdu 1509 Windows Message Queue (优先队列)

    Windows Message QueueTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. hdu1509(Windows Message Queue) 优先队列

    点击打开链接 Problem Description Message queue is the basic fundamental of windows system. For each proces ...

  8. D - Windows Message Queue

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

  9. HDU 1509 Windows Message Queue(队列)

    题目链接 Problem Description Message queue is the basic fundamental of windows system. For each process, ...

  10. H - Windows Message Queue

    Message queue is the basic fundamental of windows system. For each process, the system maintains a m ...

随机推荐

  1. Nightmare(DFS)

    Nightmare    hdu1072 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  2. What is an http upgrade?

    HTTP Upgrade is used to indicate a preference or requirement to switch to a different version of HTT ...

  3. ubuntu 中c 语言编程(学习)

    ubuntu下c编程 c编程中相关文件后缀 .a    静态库(archive .c     C源代码(需要编译预处理) .h     C源代码头文件 .i      C源代码 (不需要编译预处理) ...

  4. WPF笔记(1.6 数据绑定)——Hello,WPF!

    原文:WPF笔记(1.6 数据绑定)--Hello,WPF! 这个一节都是在讲一个数据绑定的示例.功用:输入姓和名,点击Add按钮,ListBox增加一条记录,永远是字符串“name: nick”:L ...

  5. ListView.setOnItemClickListener无效

    如果ListView中的单个Item的view中存在checkbox,button等view,会导致ListView.setOnItemClickListener无效, 事件会被子View捕获到,Li ...

  6. bzoj1644 [Usaco2007 Oct]Obstacle Course 障碍训练课

    Description 考虑一个 N x N (1 <= N <= 100)的有1个个方格组成的正方形牧场.有些方格是奶牛们不能踏上的,它们被标记为了'x'.例如下图: . . B x . ...

  7. 生成excel文件

    java操作Excel最常用的开源组件有poi与jxl.jxl是韩国人开发的,发行较早,但是更新的很慢,目前似乎还不支持excel2007.poi是apache下的一个子项目,poi应该是处理ms的o ...

  8. PHP安装和配置

    编译安装php5-5.2.6-49.11.src.rpm: ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin ...

  9. JAVA JNI

    jni非常好的一篇文章 http://m.blog.csdn.net/article/details?id=22827307 JAVA JNI介绍 http://blog.csdn.net/cyg08 ...

  10. structs2标签

    Struts2常用标签总结 一 介绍 1.Struts2的作用 Struts2标签库提供了主题.模板支持,极大地简化了视图页面的编写,而且,struts2的主题.模板都提供了很好的扩展性.实现了更好的 ...