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 ...
随机推荐
- jQuery——节点操作
创建节点 1.$():创建一个li标签 $("<li class='aaa'>我是li标签</li>") 2.html():创建一个li标签并同时添加到ul ...
- redis键的过期和内存淘汰策略
键的过期时间 设置过期时间 Redis可以为存储在数据库中的值设置过期时间,作为一个缓存数据库,这个特性是很有帮助的.我们项目中的token或其他登录信息,尤其是短信验证码都是有时间限制的. 按照传统 ...
- MVC Ajax调用Action时-OnActionExecuting RedirectResult 无法跳转的处理办法
public class BaseController : Controller { protected override void OnActionExecuting(ActionExecuting ...
- Navicat 连接docker mysql报错
解决办法: docker exec -it dc10e8b328d7 bashmysql -u root -p 输入密码 use mysql; ALTER USER 'root'@'%' IDENTI ...
- HDU3336Count the string
HDU3336Count the string Problem Description It is well known that AekdyCoin is good at string proble ...
- 手撸HashMap实现
前言 HashMap是Java中常用的集合,而且HashMap的一些思想,对于我们平时解决业务上的一些问题,在思路上有帮助,基于此,本篇博客将分析HashMap底层设计思想,并手写一个迷你版的Hash ...
- Windows Server 2008安装教程
系统简介 windows server 2008是迄今为止最灵活.最稳定的windows 操作系统.Windows server 2008 的安装过程是基于镜像文件的,主要版本:Windows Ser ...
- OSI 7层模型和 TCP/IP 5层模型
网络协议通常分不同层次进行开发,每一层分别负责不同的通行功能. 两种参考模型 OSI 和 TCP/IP, OSI 先有模型后有协议,TCP/IP 则相反. OSI 7层模型 - 应用层 - 表示层 - ...
- springcloud(六):给Eureka Server服务器端添加用户认证
1. 还未完成 ,客户端有点问题,后期完善 2.
- Django——6 模型基础ORM 数据库连接配置 模型的创建与映射 数据的增删改查
Django Django的ORM简介 数据库连接配置 模型的创建与映射 数据库的增删改查 增数据 查数据及补充 改数据 删数据 Django的ORM系统分析 ORM概念:对象关系映射(Objec ...