fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define MM ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
  4. int main(){
  5. MM
  6. int t;
  7. cin>>t;
  8. deque<int> ss;
  9. while (t--) {
  10. string s;
  11. cin>>s;
  12. if (s=="toFront") {
  13. int n;
  14. cin>>n;
  15. ss.push_front(n);
  16. }
  17. else if (s=="back") {
  18. if (!ss.empty()) {
  19. cout<<ss.back()<<'\n';
  20. ss.pop_back();
  21. }
  22. else {
  23. cout<<"No job for Ada?"<<'\n';
  24. }
  25. }
  26. else if (s=="front") {
  27. if (!ss.empty()) {
  28. cout<<ss.front()<<'\n';
  29. ss.pop_front();
  30. }
  31. else {
  32. cout<<"No job for Ada?"<<'\n';
  33. }
  34. }
  35. else if (s=="push_back") {
  36. int n;
  37. cin>>n;
  38. ss.push_back(n);
  39. }
  40. else if (s=="reverse") {
  41. reverse(ss.begin(),ss.end());
  42. }
  43. }
  44. }
Success #stdin #stdout 0.01s 5292KB
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