【优先队列】HDU 1873——看病找医生
来源:点击打开链接
看路径记录的BFS之前,再看一遍优先队列的用法。
优先队列的排序规则可以用运算符重载的方式完成,通常意义下,应该用friend bool operator <进行重载。
#include <iostream>
#include <cstring>
#include <queue>
#include <string>
using namespace std; class hospital
{
public:
int level;
int id;
friend bool operator < (hospital c1,hospital c2)
{
if(c1.level!=c2.level)
return c1.level<c2.level;
else
return c1.id>c2.id;
}
}; int main()
{
int testcase;
while(cin>>testcase)
{
int doc,level;
int as=0;
string op;
priority_queue<hospital> p[4];
hospital tmp;
while(testcase--)
{
cin>>op;
if(op=="IN")
{
as++;
cin>>doc>>level;
tmp.level=level;
tmp.id=as;
//cout<<"idis"<<tmp.id<<endl;
p[doc].push(tmp); }
else if(op=="OUT")
{
cin>>doc;
if(p[doc].empty())
cout<<"EMPTY"<<endl;
else
{
tmp=p[doc].top();
p[doc].pop();
cout<<tmp.id<<endl; }
}
} }
return 0;
}
【优先队列】HDU 1873——看病找医生的更多相关文章
- hdu 1873 看病要排队
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1873 看病要排队 Description 看病要排队这个是地球人都知道的常识.不过经过细心的0068的 ...
- HDU 1873 看病要排队 优先队列
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...
- HDU 1873 看病要排队(优先队列)
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdu 1873 看病要排队(优先级队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1873 题目大意: 三个医生看病,病人排队看病,病人有优先级,优先级高的提前看病,同样的优先级按先后.I ...
- hdu 1509 & hdu 1873 & hdu 1896 (基础优先队列)
http://acm.hdu.edu.cn/showproblem.php?pid=1509 裸的优先队列的应用,输入PUT的时候输入名字,值和优先值进队列,输入GRT的时候输出优先值小的名字和对应的 ...
- hdoj 1873 看病要排队【优先队列】
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdu——1873(优先队列)
看病要排队 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdu acm 2082 找单词
找单词 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- HDU 2086 A1 = ? (找规律推导公式 + 水题)(Java版)
Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2086 ——每天在线,欢迎留言谈论. 题目大意: 有如下方程:Ai = (Ai-1 ...
随机推荐
- 北信源VRVEIS网管软件测试
650) this.width=650;" border="0" alt="" src="http://img1.51cto.com/att ...
- 实体框架 (EF) 入门 => 三、CodeFirst 支持的完整特性列表
KeyAttribute 设置主键.如果为int类型,将自动设置为自增长列. 系统默认以Id或类名+Id作为主键.StringLengthAttribute 可设置最大最小长度以及验证提示信息等.最大 ...
- android错误系列之导出数据库出错Failed to pull selection
使用效率检视工具traceView,在导出检测文件时,出现了“failed to pull a selection”问题,网上搜索了几篇文章,有的说,是因为导出超时,我将windows-->pr ...
- Terrain & Light & Camera
[Terrain Engine] 1.When you press F, wherever your mouse is positioned will be moved to the center o ...
- A Dream
A Dream 2013年10月20日,成都,天气阴,铜牌16.离2012年10月14日长春现场赛刚好隔了一年,刚看了下去年写的总结http://blog.csdn.net/cc_again/arti ...
- springMVC+JAP整合彻底摆脱persistence.xml配置文件
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- gulp安装和使用简介
一. gulp和grunt对比 grunt目前的工作流程:读文件.修改文件.写文件——读文件.修改文件.写文件——... gulp目前的工作流程:读取文件——修改文件——修改文件...——写文件 二. ...
- CentOS FireFox Flash Player
yum install *firefox* yum install flash-plugin
- mac下xampp简单虚拟主机配置
多域名,虚拟主机的配置 开启虚拟主机配置选项: 打开httpd.conf文件,找到httpd-vhosts.conf那一行,解除该行注释: 打开httpd-vhosts.conf文件 修改如下 < ...
- cocos2dx 屏幕适配策略
cocos2dx的常用函数: CCEGLView::sharedOpenGLView()->setDesignResolutionSize() //设计分辨率大小(即开发时为基准的屏幕分辨率) ...