HDU 1509 Windows Message Queue(队列)
题解:优先队列,写的时候运算符重载一直出问题,还是不懂。而且刚开始没有加idx这个成员,就一直WA,看了看题目也没发现什么诡异的地方,最后看了几个题解,加上了idx就AC了,也不知道是为什么。
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
#define PI acos(-1.0)
#define ms(a) memset(a,0,sizeof(a))
#define msp memset(mp,0,sizeof(mp))
#define msv memset(vis,0,sizeof(vis))
using namespace std;
//#define LOCAL
struct task
{
char name[];
int value,pri,idx;
friend bool operator < (task a,task b)
{
if(a.pri==b.pri)
{
return b.idx<a.idx;
}
return b.pri<a.pri;
}
} t;
int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
ios::sync_with_stdio(false);
priority_queue<task> q;
//while(!q.empty())q.pop();
char com[];
int k=;
while(cin>>com)
{
if(com[]=='G')
{
if(q.empty())printf("EMPTY QUEUE!\n");
else printf("%s %d\n",q.top().name,q.top().value),q.pop();
}
else
{
cin>>t.name>>t.value>>t.pri;
t.idx=++k;
q.push(t);
}
}
return ;
}
HDU 1509 Windows Message Queue(队列)的更多相关文章
- hdu 1509 Windows Message Queue
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1509 Windows Message Queue Description Message queue ...
- 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 (优先队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1509 题目大意:每一次输入都有序号和优先级,优先级小的先输出,优先级相同的话则序号小的先输出!第一次用 ...
- hdoj 1509 Windows Message Queue【优先队列】
Windows Message Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- MSMQ学习笔记二——创建Message Queue队列
一.创建Message Queue队列的主要流程 1.定义MQQUEUEPROPS 结构: 2.设置消息队列属性: 3.初始化MQQUEUEPROPS 结构: 4.调用MQCreateQueue创建队 ...
- 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 ...
- zoj 2724 Windows Message Queue(使用priority_queue容器模拟消息队列)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2724 题目描述: Message queue is the b ...
随机推荐
- linux的环境变量设置
source/etc/profile是让/etc/profile文件修改后立即生效, 还有一种方法是:. /etc/profile 注意:.和/etc/profile有空格 linux中source命 ...
- Tiny6410之重定位代码到SDRAM
在上一章中,将代码重定位到了SRAM中,但是这样的做法作用不大.正确的做法的是将代码重定位到更大的主存中,即DRAM.Tiny6410的DRAM控制寄存器最多只能支持两个同一类型的芯片.每个芯片最多可 ...
- JavaSE中主要的类与方法
1.instanceof:测试左边的对象是否是右边类的实例; 数组.length:返回的是数组的长度; 2.Scanner类 nextInt():读取键盘录入的整数; next():读取键 ...
- DEBUG 调试
1.Step Into (also F5) 跳入 2.Step Over (also F6) 跳过 3.Step Return (also F7) 执行完当前method,然后return跳出此met ...
- myeclipse连接数据库oracle(添加jdbc.properties)
第一步:在src下面建一个包com.xsl.conf 第二步:在建好的包下面新建一个jdbc.properties 第三步:在jdbc.properties里写入内容如下: driver = orac ...
- Java常用术语及区别
Java中总有几个术语,平时说的多,但是还是让人有点摸不着头脑,今天就来解析一下他们的区别: l JDK:Java development toolkit,是 Java 语言的软件开发工具包(SDK) ...
- logger日志工具类
日志工厂类 package cn.itcast.utils; import java.util.logging.FileHandler; import java.util.logging.Handle ...
- 得分(Score, ACM/ICPC Seoul 2005,UVa 1585)
#include<cstdio>#include<cstdlib>#include<cstring>int main(){ char s[80];//输入OOXXO ...
- ubuntu jdk环境变量配置
export JAVA_HOME=/usr/local/java/jdk1.8.0_25 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:$ ...
- oracle之nomount、mount、open三种状态
1.先来看下外国网站上的资料怎么说 Nomount – The database instance has been started (processes and memory structures ...