标签:
考察优先队列,以及对队列的一系列操作
#include<iostream>
#include<queue>
int n;
using namespace std;
struct stu
{
int num,po;
friend bool operator<(stu x,stu y)
{
if(x.po==y.po) return x.num>y.num;
return x.po<y.po;
}
};
priority_queue<stu>mapp[4];
string cmd;
stu d;
int main()
{
while(cin>>n)
{
for(int i=0;i<4;i++)
{
while(mapp[i].size()) mapp[i].pop();
}
int t=1;
for(int i=1;i<=n;i++)
{
cin>>cmd;
if(cmd=="IN")
{
int x,y;
cin>>x>>y;
d.num=t;d.po=y;t++;
mapp[x].push(d);
}
else
{
int x;
cin>>x;
if(mapp[x].size())
{
cout<<mapp[x].top().num<<endl;
mapp[x].pop();
}
else
{
cout<<"EMPTY"<<endl;
}
}
}
}
return 0;
} 标签:
原文地址:http://blog.csdn.net/zafkiel_nightmare/article/details/45177361