fork download
  1. #include<iostream>
  2. #include <limits.h>
  3. #include<iomanip>
  4. #include<cmath>
  5. #include<algorithm>
  6. #include<string>
  7. #include<vector>
  8. #include<bits/stdc++.h>
  9. using namespace std ;
  10. int main()
  11. {
  12. ios_base::sync_with_stdio(false),cin.tie(nullptr), cout.tie(nullptr);
  13. int num; cin >> num;
  14. deque <int>a;
  15. for (int i = 0; i < num; i++)
  16. {
  17. string n; cin >>n;
  18. if(n=="back")
  19. {
  20. if(!a.empty())
  21. {
  22. cout << a.back()<<'\n';
  23. a.pop_back();
  24. }
  25. else cout << "No job for Ada?"<<'\n';
  26. }
  27. if(n=="front")
  28. {
  29. if(!a.empty())
  30. {
  31. cout <<a.front()<<'\n';
  32. a.pop_front();
  33. }
  34. else cout <<"No job for Ada?"<<'\n';
  35. }
  36. if(n=="reverse")
  37. {
  38. reverse(a.begin(),a.end());
  39. }
  40. if(n=="push_back")
  41. {
  42. int nu; cin >>nu;
  43. a.push_back(nu);
  44. }
  45. if(n=="toFront")
  46. {
  47. int nu; cin >>nu;
  48. a.push_front(nu);
  49. }
  50. }
  51. return 0;
  52.  
  53. }
Success #stdin #stdout 0s 5316KB
stdin
15
toFront 93
front
back
reverse
back
reverse
toFront 80
push_back 53
push_back 50
front
front
reverse
push_back 66
reverse
front
stdout
93
No job for Ada?
No job for Ada?
80
53
66