Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<math.h>
- #include<ctype.h>
- #include<stdlib.h>
- #include<cstdio>
- #include<cstring>
- #include<string>
- #include<cmath>
- #include<iostream>
- #include<cctype>
- #include<map>
- #include<stack>
- #include<cstdlib>
- #include <queue>
- #include <vector>
- #include<algorithm>
- using namespace std;
- typedef long int LD;
- typedef long long int LLD;
- typedef float F;
- typedef double LF;
- typedef unsigned int U;
- typedef unsigned long int LU;
- typedef unsigned long long int LLU;
- typedef char C;
- #define sf scanf
- #define pf printf
- #define PI acos(-1.0)
- #define sq(x) (x)*(x)
- #define MAX(x,y) (x>y)?x:y
- #define MIN(x,y) (x<y)?x:y
- #define MAX3(x,y,z) (x>y)?((x>z)?x:z):((y>z)?((y>x)?y:x):z)
- #define MIN3(x,y,z) (x<y)?((x<z)?x:z):((y<z)?((y<x)?y:x):z)
- #define nn printf("\n")
- //#define sz 1005
- /****** start your code *******/
- int main()
- {
- int n,a,b,i,nt,im,q,p,s,coun;
- while(sf("%d",&n)!=EOF)
- {
- queue<int>qu;
- priority_queue<int>pqu;
- stack<int>stk;
- nt=im=q=p=s=coun=0;
- for(i=0; i<n; i++)
- {
- sf("%d%d",&a,&b);
- switch(a)
- {
- case 1:
- {
- qu.push(b);
- pqu.push(b);
- stk.push(b);
- }
- break;
- case 2:
- {
- int x,y,z;
- x=y=z=102;
- coun++;
- if(!qu.empty())
- {
- x=qu.front();
- qu.pop();
- }
- if(!pqu.empty())
- {
- y=pqu.top();
- pqu.pop();
- }
- if(!stk.empty())
- {
- z=stk.top();
- stk.pop();
- }
- if((x==b && y==b)||(x==b && z==b)|| (z==b && y==b))
- nt++;
- if(x==b)
- q++;
- if(y==b)
- p++;
- if(z==b)
- s++;
- if(x!=b && y!=b && z!=b)
- im++;
- }
- //break;
- }
- }
- if(nt==coun)
- pf("not sure\n");
- else if(q==coun)
- pf("queue\n");
- else if(p==coun)
- pf("priority queue\n");
- else if(s==coun)
- pf("stack\n");
- else if(im==coun)
- pf("impossible\n");
- else
- pf("impossible\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment