题目地址:https://vjudge.net/problem/UVA-11995
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<=(int)(b);++i)
#define REPD(i,a,b) for(int i=a;i>=(int)(b);--i)
stack<int> s;
queue<int> q;
priority_queue<int> PQ;
int main(int argc, char const *argv[])
{int n;while(cin>>n){int c,x;bool st,qu,pq;while(!s.empty()) s.pop();while(!q.empty()) q.pop();while(!PQ.empty()) PQ.pop();st=qu=pq=true;REP(i,1,n) {cin>>c>>x;if(c==1) {s.push(x);q.push(x);PQ.push(x);}else {if(s.empty()||s.top()!=x) st=false;else s.pop();if(q.empty()||q.front()!=x) qu=false;else q.pop();if(PQ.empty()||PQ.top()!=x) pq=false;else PQ.pop();}}if(st+qu+pq==0) printf("impossible\n");else if(st+qu+pq>1) printf("not sure\n");else {if(st) printf("stack\n");if(qu) printf("queue\n");if(pq) printf("priority queue\n");}}return 0;
}