hdu1509 Windows Message Queue
2015-07-28 15:33
483 查看
本题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1509
本题运用优先队列来解决,并运用了结构体的一些知识,AC代码如下:
本题运用优先队列来解决,并运用了结构体的一些知识,AC代码如下:
#include<stdio.h> #include<queue> #include<string.h> using namespace std; struct node{ char name[100]; int x,y; int num; friend bool operator < (node a,node b) { if(a.y!=b.y) return a.y>b.y; else return a.num>b.num; } }; int main() { priority_queue <node> q; char a[100]; int count=1; node Q; while(scanf("%s",a)!=EOF) { if(!strcmp(a,"GET")) { if(q.empty()) printf("EMPTY QUEUE!\n"); else { printf("%s %d\n",q.top().name,q.top().x); q.pop(); } } else if(!strcmp(a,"PUT")) { scanf("%s %d %d",Q.name,&Q.x,&Q.y); Q.num=count; count++; q.push(Q); } } return 0; }
相关文章推荐
- easyui-combobox加载json中对象的属性(转)
- easyui datagrid
- HDOJ 1509 Windows Message Queue (简单优先队列 )
- 225.Implement Stack using Queues (用队列实现栈)
- iOS总结控件三(UItextField)
- 在 UITabBarController 和 UINavigationController tableView被navigati
- iOS阶段学习第26天笔记(UILabel的介绍)
- Fragment 中嵌套Fragment,更新数据,UI
- leetcode 063 —— Unique Paths II
- UVA 540 Team Queue
- UIBarButtonItem类目-返回一个有图片的导航栏按钮
- IOS8 UITableViewCell线填充方法 不显示多余cell分割线
- HDU 1509 Windows Message Queue
- RegQueryValueEx函数不能获取到键值?
- hdoj 1509 Windows Message Queue【优先队列】
- android常用UI使用案例:ImageSwitcher和Gallery
- 【kmp】hdu1171 Number Sequence
- leetcode 062 —— Unique Paths
- android常用UI使用案例:SeekBar
- FineUI初学手册-部分JS整理