- #include<iostream>
- #include<queue>
- #include<algorithm>
- #include<cstring>
- usingnamespacestd;
- structnode
- {
- charname[1000];
- intparameter;
- intpriority;
- intnum;//这里出错了。。。应该加个先后顺序排序。。。类似上次HDU做的队列里的一题,
- friendbooloperator<(nodea,nodeb)
- if(b.priority==a.priority)
- returnb.num<a.num;
- returnb.priority<a.priority;
- }
- };
- intmain()
- priority_queue<node>q;
- charstr[100];
- nodetemp;
- intnum=0;
- while(~scanf("%s",str))
- if(strcmp(str,"GET")==0)
- if(!q.empty())
- temp=q.top();
- printf("%s%d\n",temp.name,temp.parameter);
- q.pop();
- }
- else
- printf("EMPTYQUEUE!\n");
- else
- {
- scanf("%s%d%d",&temp.parameter,&temp.priority);
- temp.num=num++;
- q.push(temp);
- }