fork download
  1. #include <bits/stdc++.h>
  2. #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  3. #define ll long long
  4. #define ss string
  5. #define db double
  6. #define endl '\n'
  7. #define pi 3.1415927
  8. #define outd fixed << setprecision(6)
  9. #define all(x) (x).begin(), (x).end()
  10. #define rall(x) (x).rbegin(), (x).rend()
  11. using namespace std;
  12. const int N=1e6;
  13. int main() {
  14. IOS
  15. deque<int> dq;
  16. int q;
  17. cin>>q;
  18. while(q--) {
  19. ss s;
  20. cin>>s;
  21. if(s=="toFront") {
  22. int x; cin>>x;
  23. dq.push_front(x);
  24. }
  25. else if(s=="push_back") {
  26. int x; cin>>x;
  27. dq.push_back(x);
  28. }
  29. else if(s=="front") {
  30. if(dq.empty()) {
  31. cout<<"No job for Ada?\n";
  32. }
  33. else {
  34. cout<<dq.front()<<endl;
  35. }
  36. }
  37. else if(s=="back") {
  38. if(dq.empty()) {
  39. cout<<"No job for Ada?\n";
  40. }
  41. else {
  42. cout<<dq.back()<<endl;
  43. }
  44. }
  45. else if(s=="reverse") {
  46. reverse(all(dq));
  47. }
  48. }
  49. return 0;
  50. }
  51.  
  52.  
Success #stdin #stdout 0s 5264KB
stdin
Standard input is empty
stdout
Standard output is empty