-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhang_doi_1.cpp
More file actions
57 lines (56 loc) · 1.11 KB
/
hang_doi_1.cpp
File metadata and controls
57 lines (56 loc) · 1.11 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<queue>
#include<stack>
#include<string>
using namespace std;
long long mod = 1e9 + 7;
void slove(){
queue<int> q;
int n;
cin >> n;
int k;
while (n--){
cin >> k;
switch (k)
{
case 1:
cout << q.size() << "\n";
break;
case 2:
if(!q.empty()) cout << "NO\n";
else cout << "YES\n";
break;
case 3:
int x;
cin >> x;
q.push(x);
break;
case 4:
if(!q.empty()) q.pop();
break;
case 5:
if(!q.empty()) cout << q.front() << "\n";
else cout << "-1\n";
break;
case 6:
if(!q.empty()) cout << q.back() << "\n";
else cout << "-1\n";
break;
default:
break;
}
}
}
int main(){
int t=1;
cin >> t;
while(t--){
slove();
}
return 0;
}