-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10845.cpp
38 lines (34 loc) · 827 Bytes
/
10845.cpp
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
38
#include<bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(0);
cin.tie(0);
int N;
cin>>N;
queue<int> Q;
string op;
while(N--){
cin>>op;
if(op=="push"){
int input;
cin>>input;
Q.push(input);
}else if(op=="pop"){
if(Q.empty()) cout<<"-1\n";
else
{ cout<<Q.front()<<"\n";
Q.pop();
}
}else if(op=="back"){
if(Q.empty()) cout<<"-1\n";
else cout<<Q.back()<<"\n";
}else if(op=="empty"){
cout<<Q.empty()<<"\n";
}else if(op=="front"){
if(Q.empty()) cout<<"-1\n";
else cout<<Q.front()<<"\n";
}else if(op=="size"){
cout<<Q.size()<<"\n";
}
}
}