#P1210. Windows Message Queue
Windows Message Queue
题目描述
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.
翻译:维护一个消息队列,每个消息有三个值 名称 参数(属性?) 优先值,优先值小的优先级高,每次询问得到的都是优先级最高的消息
输入格式
The first line of input contains one positive integer n, 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.
翻译:第一行n个数表示有n条命令(1<=n<= 60000 ),随后n行每一行都是一个命令,“GET”或“PUT”,意思是获取消息或放置消息。如果命令为“PUT”,则有一个字符串表示消息名称,两个整数表示参数和优先级。请注意,一条消息可能出现两次或两次以上,如果两条消息具有相同的优先级,则将首先处理最先出现的消息。
输出格式
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.
翻译:对于每个“GET”命令,输出从消息队列中获取的命令,名称和参数在一行中。如果队列中没有消息,则输出“EMPTY QUEUE!”。 “PUT”命令没有输出。
提示:
每次"GET"获取消息后,这个消息则会再消息队列清除
样例
6
GET
PUT msg1 10 5
PUT msg2 10 4
GET
GET
GET
EMPTY QUEUE!
msg2 10
msg1 10
EMPTY QUEUE!
Limitation
1s, 1024KiB for each test case.
Related
In following contests: