fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int n,a,b;
  5. int q,s,p;
  6. while(cin>>n){
  7. queue<int> Q;
  8. stack<int> S;
  9. priority_queue<int> P;
  10. q=1;
  11. s=2;
  12. p=3;
  13. while(n--){
  14. cin>>a>>b;
  15. if(a==1){
  16. Q.push(b);
  17. S.push(b);
  18. P.push(b);
  19. }
  20. else if(a==2){
  21. if(!Q.empty()&&Q.front()==b)Q.pop();
  22. else q=0;
  23. if(!S.empty()&&S.top()==b)S.pop();
  24. else s=0;
  25. if(!P.emty()&&P.top()==b)P.pop();
  26. else p=0;
  27. }
  28. }
  29. int ans=max( max(q,p) , s);
  30. if(!ans)cout<<"impossible"<<endl;
  31. else if((q&&p)||(q&&s)||(s&&p)||(q&&p&&s))cout<<"not sure"<<endl;
  32. else if(q)cout<<"queue"<<endl;
  33. else if(s)cout<<"stack"<<endl;
  34. else if(p)cout<<"priority queue"<<endl;
  35. }
  36. return 0;
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
6
1 1
1 2
1 3
2 1
2 2
2 3
6
1 1
1 2
1 3
2 3
2 2
2 1
2
1 1
2 2
4
1 2
1 1
2 1
2 2
7
1 2
1 5
1 1
1 3
2 5
1 4
2
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:25:11: error: ‘class std::priority_queue<int>’ has no member named ‘emty’; did you mean ‘empty’?
     if(!P.emty()&&P.top()==b)P.pop();
           ^~~~
stdout
Standard output is empty