fork download
  1. #include<bits/stdc++.h>
  2. #include<iostream>
  3. // #include<queue>
  4. using namespace std;
  5.  
  6. int main() {
  7. int t;
  8. cin>>t;
  9.  
  10. pair<int,int> pair1;
  11. queue<int>q;
  12.  
  13. while(t--) {
  14. cin>>pair1.first>>pair1.second;
  15. if(pair1.first==1) {
  16. q.push(pair1.second);
  17. }else if(pair1.first==2) {
  18. q.pop();
  19. }else if(pair1.first==3) {
  20. cout<<q.front()<<endl;
  21. }else if(q.empty()) {
  22. cout<<"Empty!"<<endl;
  23. }
  24. cout<<q.front()<<endl;
  25. }
  26.  
  27. }
  28.  
Success #stdin #stdout 0.01s 5284KB
stdin
6
1 5
1 6
2
3
2
3
stdout
5
5
6
0
0
0