-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.cpp
More file actions
37 lines (32 loc) · 702 Bytes
/
Copy pathqueue.cpp
File metadata and controls
37 lines (32 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double>pdd;
const int N=1e5+10,M=1e5+10,INF=0x3f3f3f3f,MOD=1e9+7;
const double EPS=1e-8;
int n,m;
int q[N],qh,qt;
int main(){
scanf("%d",&n);
qt=-1;
while(n--){
char op[6];
int x;
scanf("%s",op);
if(!strcmp(op,"push")){
scanf("%d",&x);
q[++qt]=x;
}
else if(!strcmp(op,"pop")){
qh++;
}
else if(!strcmp(op,"empty")){
if(qh>qt){
printf("YES\n");
}
else printf("NO\n");
}
else printf("%d\n",q[qh]);
}
}