zoj 2724
2013-07-30 21:52
344 查看
看了priority_queue的用法,才做这道题,很简单.
#include <iostream> #include <queue> #include <string> using namespace std; struct mesg{ string str; int para; int prio; mesg(int a = 0): prio(a) {} }; bool operator<(mesg a, mesg b){ return a.prio > b.prio; } using namespace std; int main() { priority_queue<mesg> q; string s; while(cin>>s){ if( s == "GET" ){ if(q.empty()) cout<<"EMPTY QUEUE!"<<endl; else{ cout<<q.top().str<<" "<<q.top().para<<endl; q.pop(); } } else{ mesg m; cin>>m.str>>m.para>>m.prio; q.push(m); } } return 0; }
相关文章推荐
- ZOJ - 2724 Windows Message Queue (优先队列)
- zoj-2724 Windows Message Queue(二叉堆&&优先队列)
- ZOJ 2724 Windows Message Queue(二叉堆||优先队列)
- ZOJ 2724 Windows Message Queue 堆
- zoj_2724 Windows Message Queue
- ZOJ-2724-Windows Message Queue
- STL 的题目练习(HDU1263 HDU1075 HDU 1004 ZOj 2724)
- ZOJ 2724 Windows Message Queue
- ZOJ-2724-Windows Message Queue
- zoj - 2724 - Windows Message Queue
- zoj 2724 Windows Message Queue(使用priority_queue容器模拟消息队列)
- zoj 2724 Windows Message Queue 优先队列
- zoj - 2724 - Windows Message Queue
- zoj 2724 Windows Message Queue
- zoj 2724 Windows Message Queue 优先队列
- ZOJ 2724 Windows 消息队列 (优先队列)
- 【每日一题(12)】Windows Message Queue ZOJ - 2724
- ZOJ 2724
- ZOJ 2724 Windows Message Queue (优先级队列,水题,自己动手写了个最小堆)
- ZOJ 2724Windows Message Queue