링크 : https://www.acmicpc.net/problem/18258
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n = 0;
cin >> n;
queue<int> q;
for(int i = 0; i < n; i ++){
string s;
cin >> s;
if(s == "push"){
int num = 0;
cin >> num;
q.push(num);
}
else if(s == "pop"){
if(q.empty()) cout << "-1" << "\n";
else {
cout << q.front() << "\n";
q.pop();
}
}
else if(s == "size") cout << q.size() << "\n";
else if(s == "empty"){
if(q.empty()) cout << "1" << "\n";
else cout << "0" << "\n";
}
else if(s == "front"){
if(q.empty()) cout << "-1" << "\n";
else cout << q.front() << "\n";
}
else if(s == "back"){
if(q.empty()) cout << "-1" << "\n";
else cout << q.back() << "\n";
}
}
return 0;
}