来源hdu1509

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!

按价值排序,优先队列水题

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iomanip>
#include<cmath>
#include<float.h>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define scf(x) scanf("%d",&x)
#define scff(x,y) scanf("%d%d",&x,&y)
#define prf(x) printf("%d\n",x)
#define mm(x,b) memset((x),(b),sizeof(x))
#include<vector>
#include<queue>
#include<map>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
typedef long long ll;
const ll mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
using namespace std;
const double pi=acos(-1.0);
const int N=3e2+10;
class mes
{
public:
char name[50];
int cnt;
int num,val;
friend bool operator <(mes a,mes b)
{
if(a.val==b.val)
return a.cnt>b.cnt;
return a.val>b.val;
}
};
priority_queue<mes> v;
void print(mes a)
{
pf("%s %d\n",a.name,a.num);
}
int main()
{
int cas=1;
char a[5];
while(~sf("%s",a))
{
if(a[0]=='G')
{
if(v.empty())
pf("EMPTY QUEUE!\n");
else
{
print(v.top());
v.pop();
} }else
{
mes t;
t.cnt=cas++;
sf("%s%d%d",t.name,&t.num,&t.val);
v.push(t);
}
}
return 0;
}

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

  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. HDU 1509 Windows Message Queue(队列)

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

  8. H - Windows Message Queue

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

  9. zoj 2724 Windows Message Queue(使用priority_queue容器模拟消息队列)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2724 题目描述: Message queue is the b ...

随机推荐

  1. 用SSH登录远程的机器,在远程机器上执行本地机器上的脚本

    假设本地的机器IP为10.245.111.90,我们想要在10.245.111.93上执行一个保存在10.245.111.90上的脚本. 经过测试通过的命令如下: ssh root@10.245.11 ...

  2. ubuntu16.04 npm安装

    $ sudo apt-get install python-software-properties $ curl -sL https://deb.nodesource.com/setup_6.x | ...

  3. 尝试新的构造系统 Ninja

    Ninja 是 Chrome 项目的构建工具,用来替换经典工具 make,目前这个开源工具已经被很多其它项目采用.据项目作者描述,创建这个新的构建工具,主要是为了提升大型项目的编译速度. 由于 Nin ...

  4. lua变量作用域

    3.5 – Visibility Rules Lua is a lexically scoped language. The scope of a local variable begins at t ...

  5. MySQL技术内幕读书笔记(二)——InnoDB存储引擎

    目录 InnoDB存储引擎 InnoDB存储架构 Checkpoint技术 Master Thread 工作方式 InnoDB关键特性(放一下,感觉看后面,再看总结吧) InnoDB存储引擎 Inno ...

  6. Spring Boot常见配置及错误

    一.SpringBoot常见配置 (1)SpingBoot与MyBatis集成时跟踪SQL语句 log4j: logger: java: sql: ResultSet: TRACE (2)日志跟踪 d ...

  7. Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer 关于Newtonsoft.Json,LINQ to JSON的一个小demo mysql循环插入数据、生成随机数及CONCAT函数 .NET记录-获取外网IP以及判断该IP是属于网通还是电信 Guid的生成和数据修整(去除空格和小写字符)

    Visual Studio 2017 - Windows应用程序打包成exe文件(2)- Advanced Installer   Advanced Installer :Free for 30 da ...

  8. 【Inno Setup】添加许可协议,并默认选中我同意按钮

      [Setup] ; xkfile.txt文件不能为空 LicenseFile=C:\Documents and Settings\Administrator\桌面\smqh\xkfile.txt ...

  9. Down Payment 和 Deposit的差异

    If you’re like most homeowners, purchasing a home represents the single biggest financial transactio ...

  10. Centos7.4 安装Docker

    一.安装docker yum install -y docker 二.启动docker服务 systemctl start docker 三.设置成开机启动docker服务 systemctl ena ...