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. __m128i的理解[转]

    __m128i被称为128bits的整数,当我们对其赋值时,调用 __m128i _mm_set1_epi32(int i) Sets the four signed 32-bit integer v ...

  2. 小希的迷宫(HDU 1272 并查集判断生成树)

    小希的迷宫 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  3. 美国政府关于Google公司2013年度的财务报表红头文件

    请管理员移至新闻版块,谢谢! 来源:http://www.sec.gov/ 财务报表下载↓ 此文仅作参考分析. 10-K 1 goog2013123110-k.htm FORM 10-K   UNIT ...

  4. SPOJDIVCNT2: Counting Divisors(莫比乌斯反演)

    http://acm.tzc.edu.cn/acmhome/vProblemList.do?method=problemdetail&oj=SPOJ&pid=DIVCNT2 给出n求 ...

  5. 51单片机实现对24C02进行页写、顺序读取并显示验证

    //************************************************************************************* //**程序名称:51单 ...

  6. 十大面试问题解惑,秒杀一切HR、技术面试

    最能体现求职者能力的就是面试,能不能拿到Offer,取决于你面试时的表现,只有有准备才能在面试过程中游刃有余.小编收集了10个面试官最爱提的问题,虽然题目千变万化,但是万变不离其宗,只要掌握了答题的技 ...

  7. Linux的环境变量配置

    以下都是环境变量相关的配置文件 1)/etc/enviroment 是系统的环境变量. (2)/etc/profile: 是所有用户的环境变量.当用户第一次登录时,该文件被执行. 并从/etc/pro ...

  8. Oracle使用NLSSORT函数实现汉字的排序

    1).按拼音首字母排序 SELECT * FROM T_TABLE ORDER BY NLSSORT(NAME, 'NLS_SORT=SCHINESE_PINYIN_M'); 2).按笔画排序SELE ...

  9. 采用标准c进行目录文件遍历

    图像处理的时候经常需要对一个目录的所有图像进行处理,遍历文件得c代码: 在windows中需要使用到宽字符. 另外,可以使用opencv封装的目录访问操作,下次给出. // DirTraverse.c ...

  10. SQL注入原理深度解析

    本文转自:http://www.iii-soft.com/forum.php?mod=viewthread&tid=1613&extra=page%3D1 对于Web应用来说,注射式攻 ...