hdoj- Windows Message Queue
Windows Message 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.
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.
GET
PUT msg1 10 5
PUT msg2 10 4
GET
GET
GET
EMPTY QUEUE!
msg2 10
msg1 10
EMPTY QUEUE!
代码
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
struct Message
{
char str[100];
int l;
int z;
int por;
friend bool operator < (Message a,Message b)
{
if(a.por==b.por)
return a.z>b.z;
else return a.por>b.por;
}
};
int main()
{
int i,j,z=1;
Message message1;
Message message2;
char mess[100];
priority_queue<Message>q;
while(!q.empty()) q.pop();
while(~scanf("%s",mess))
{ if(strcmp(mess,"PUT")==0)
{
message1.z=z++;
scanf("%s%d%d",message1.str,&message1.l,&message1.por);
q.push(message1);
} if(strcmp(mess,"GET")==0)
{
if(q.empty()==1)
printf("EMPTY QUEUE!\n");
else
{
message2=q.top();
q.pop();
printf("%s %d\n",message2.str,message2.l);
}
}
}
return 0;
}
hdoj- Windows Message Queue的更多相关文章
- hdoj 1509 Windows Message Queue【优先队列】
Windows Message Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- hdu 1509 Windows Message Queue
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1509 Windows Message Queue Description Message queue ...
- Windows Message Queue(优先队列)
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Windows Message Queue Time Limit: 2000/1000 MS (Java/Others) Mem ...
- Windows Message Queue
Windows Message Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- 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 ...
随机推荐
- Canvas清空
当canvs与bitmap绑定时,canvas上绘制会导致bitmap改变内容,而且内容时叠加的.这时候需要清空bitmap上的内容,可以用以下做法. Paint paint = new Paint( ...
- HTML CSS, JavaScript 计算器
效果图: 代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...
- CDR软件-CorelDRAW软件下载,618活动
618我有诚意,你呢? 不花钱的618,是残缺的618 给自己一个放肆shopping的机遇 活动力度不够大? 继续升级,终极体验 618疯狂倒计时! 同志们,如果你错过了之前的抢先购和升级活动 那么 ...
- Django - app
1.app目录 migrations:数据库操作的记录(只记录修改表结构的记录); __init__文件:python2中必须填加,python3中无要求,可以不添加: admin:django为我们 ...
- P4047 [JSOI2010]部落划分(最小生成树)
题目描述 聪聪研究发现,荒岛野人总是过着群居的生活,但是,并不是整个荒岛上的所有野人都属于同一个部落,野人们总是拉帮结派形成属于自己的部落,不同的部落之间则经常发生争斗.只是,这一切都成为谜团了——聪 ...
- Luogu P1041 [2003NOIP提高组]传染病控制
P1041 传染病控制 题目背景 近来,一种新的传染病肆虐全球.蓬莱国也发现了零星感染者,为防止该病在蓬莱国大范围流行,该国政府决定不惜一切代价控制传染病的蔓延.不幸的是,由于人们尚未完全认识这种传染 ...
- SQLServer中的Cross Apply、Outer Apply
https://www.2cto.com/database/201304/206330.html
- oracle 增量备份恢复策略(基础知识)
EXP和IMP是Oracle提供的一种逻辑备份工具.逻辑备份创建数据库对 象的逻辑拷贝并存入一个二进制转储文件.这种逻辑备份需要在数据库启动的情况下使用, 其导出实质就是读取一个数据库记录集(甚至可以 ...
- [bzoj2502]清理雪道[上下界网络流]
bzoj状态里有两种,一种时间是个位数,一种是四位数,我就是四位数的那种,,,估计都是看了hzwer.. #include <bits/stdc++.h> #define INF 0x3f ...
- py文件控制台执行时,报错:引入的模块不存在
1.描述:该模块在IDE中是可以正确执行的.但是从cmd控制台执行时,报错:该模块引入的其他模块不存在. 2.解决:在该模块的#encoding:utf-8 之后另起一行加如下代码: #encodin ...