HDU1873
题解:裸题,注意队列要清空,记下优先队列模板;
Code:
#include <cstdio>
#include <queue>
using namespace std;
struct p
{
int no;
int level;
friend bool operator <(p a,p b)
{
if(a.level==b.level)return a.no>b.no;
return a.level<b.level;
}
};
priority_queue<struct p> xq[5];
int main()
{
int n,a,b;
char s[100];
while(scanf("%d",&n)!=EOF)
{
int k=0;
for(int i=1;i<=3;i++)
while(!xq[i].empty())xq[i].pop();//****
for(int i=1; i<=n; i++)
{
scanf(" %s %d",s,&a);
if(s[0]=='I')
{
scanf("%d",&b);
p x;
x.level=b;
x.no=(++k);
xq[a].push(x);
}
else if(s[0]=='O')
{
if(xq[a].empty())
{
printf("EMPTY\n");
}
else
{
printf("%d\n",(xq[a].top()).no);
xq[a].pop();
}
}
}
}
return 0;
}