File tree Expand file tree Collapse file tree 1 file changed +36
-3
lines changed Expand file tree Collapse file tree 1 file changed +36
-3
lines changed Original file line number Diff line number Diff line change 1
1
// Authored by : BaaaaaaaaaaarkingDog
2
2
// Co-authored by : -
3
- // http://boj.kr/****************
3
+ // http://boj.kr/ef22176f28054f269d7a61e4356f3660
4
4
#include < bits/stdc++.h>
5
5
using namespace std ;
6
6
7
- int main (void ){
7
+ int main (void ) {
8
8
ios::sync_with_stdio (0 );
9
9
cin.tie (0 );
10
10
11
- }
11
+ queue<int > Q;
12
+ int n;
13
+ cin >> n;
14
+ while (n--){
15
+ string q;
16
+ cin >> q;
17
+ if (q==" push" ){
18
+ int val;
19
+ cin >> val;
20
+ Q.push (val);
21
+ }
22
+ else if (q==" pop" ){
23
+ if (Q.empty ()) cout << -1 << ' \n ' ;
24
+ else {
25
+ cout << Q.front () << ' \n ' ;
26
+ Q.pop ();
27
+ }
28
+ }
29
+ else if (q==" size" ){
30
+ cout << Q.size () << ' \n ' ;
31
+ }
32
+ else if (q==" empty" ){
33
+ cout << Q.empty () << ' \n ' ;
34
+ }
35
+ else if (q==" front" ){
36
+ if (Q.empty ()) cout << -1 << ' \n ' ;
37
+ else cout << Q.front () << ' \n ' ;
38
+ }
39
+ else { // back
40
+ if (Q.empty ()) cout << -1 << ' \n ' ;
41
+ else cout << Q.back () << ' \n ' ;
42
+ }
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments