Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <map>
  5. #include <deque>
  6. #include <queue>
  7. #include <set>
  8. #include <cmath>
  9. #include <string>
  10. #include <algorithm>
  11. #include <iomanip>
  12. #include <stack>
  13. typedef long long ll;
  14. typedef long double ld;
  15. const int N = int(1e5) + 111;
  16. const int INF = int(1e9) + 111;
  17. const ll LINF = ll(1e18) + 111;
  18. const ld EPS = 1e-7;
  19. const ld PI = 3.141592653589793238462643;
  20. const ll MOD = ll(1e9) + 7;
  21. #define pb push_back
  22. #define all(v) v.begin(), v.end()
  23. #define sz(v) v.size()
  24. #define x first
  25. #define y second
  26. #define watch(el) cout << #el << " " << el << endl;
  27. using namespace std;
  28. template<typename T> inline istream &operator >> (istream &in, vector<T> &v) { for (auto &i : v) { in >> i; } return in; }
  29. template<typename T> inline ostream &operator<< (ostream &out, const vector<T> &v) { for (auto &it : v) { out << it << " "; } return out; }
  30. template<typename T, typename F> inline ostream &operator<< (ostream &out, const map<T, F> &v) { for (auto &it : v) { out << "(" << it.first << ":" << it.second << ") "; } return out; }
  31.  
  32. int main() {
  33.     ios_base::sync_with_stdio(0);
  34.     cin.tie(0);
  35.     //ifstream cin("input.txt");
  36.     //ofstream cout("output.txt");
  37.     deque<string> q;
  38.     int n;
  39.     cin >> n;
  40.     for (int i = 0; i < n; i++) {
  41.         string cmd;
  42.         cin >> cmd;
  43.         if (cmd == "Run") {
  44.             string s;
  45.             getline(cin, s);
  46.             s = s.substr(1, s.size() - 1);
  47.             q.push_front(s);
  48.             cout << s << endl;
  49.         }
  50.         else {
  51.             int k = ((cmd.size() - 3) / 4)%q.size();
  52.             for (int j = 0; j < k; j++) {
  53.                 string tmp = q.front();
  54.                 q.pop_front();
  55.                 q.push_back(tmp);
  56.             }
  57.             cout << q.front() << endl;
  58.         }
  59.        
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement