【优先队列】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 ...
随机推荐
- yum 安装 php5.6 和 mysql5.6
安装 PHP rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm; rpm - ...
- erlang 时间处理
常用代码 date()返回P{年,月,日} erlang:now转本地时间 > calendar:now_to_local_time(erlang:now()). {{,,},{,,}} erl ...
- POJ2406----Power Strings解题报告
Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 43514 Accepted: 18153 D ...
- air 移动开发配置文件详解
转自http://www.badyoo.com/index.php/2012/09/12/208/index.html 目录 所需的 AIR 运行时版本 应用程序标识 应用程序版本 主应用程序 SWF ...
- android 源码 中修改系统字体大小
在源码\android\frameworks\base\core\java\android\content\res \Configuration.java下有读取DEFAULT_FONTSCALE的值 ...
- MVC缓存的使用
MVC3缓存之一:使用页面缓存 在MVC3中要如果要启用页面缓存,在页面对应的Action前面加上一个OutputCache属性即可. 我们建一个Demo来测试一下,在此Demo中,在View的Hom ...
- MyEclipse中消除frame引起的“the file XXX can not be found.Please check the location and try again.”的错误
读者如要转载,请标明出处和作者名,谢谢. 地址01:http://space.itpub.net/25851087 地址02:http://www.cnblogs.com/zjrodger/ 作者名: ...
- django 命名空间详解
include(module[, namespace=None, app_name=None ]) include(pattern_list) include((pattern_list, app_n ...
- hdu 1084 What Is Your Grade?
http://acm.hdu.edu.cn/showproblem.php?pid=1084 What Is Your Grade? Time Limit: 2000/1000 MS (Java/Ot ...
- 配置cisco路由器特定时间重启
方法一: Router1#reload in 20 Reload scheduled for 11:33:53 EST Sat Feb 1 2003 (in 20 minutes) Proceed w ...