作者:mobiledu2502923487 | 来源:互联网 | 2023-10-09 20:22
1.STL栈
hdu 1237 ‘简单计算器’
2.STL 优先队列 priority_queue
hdu 1873 看病要排队
#include
#include
//加这个文件是因为杭电的oj不行
#include<string>
using namespace std;
struct Node{
int n, p;
bool operator <(const Node &t) const {
if (p == t.p) return n > t.n;
return p < t.p;
}
}node;
int main() {
int n, id, doc;
string temp;
//没有输入scanf返回-1
while (~scanf("%d", &n)) {
id = 0;
priority_queue q[3];
while (n--) {
cin>>temp;
if (temp == "IN") {
scanf("%d%d", &doc, &node.p);
node.n = ++id;
q[doc - 1].push(node);
}else {
scanf("%d", &doc);
if (q[doc - 1].empty())
cout <<"EMPTY" << endl;
else {
node = q[doc - 1].top();
q[doc - 1].pop();
cout <endl;
}
}
}
}
return 0;
}
acm刷题