Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <map>
- #include <deque>
- #include <queue>
- #include <set>
- #include <cmath>
- #include <string>
- #include <algorithm>
- #include <iomanip>
- #include <stack>
- typedef long long ll;
- typedef long double ld;
- const int N = int(1e5) + 111;
- const int INF = int(1e9) + 111;
- const ll LINF = ll(1e18) + 111;
- const ld EPS = 1e-7;
- const ld PI = 3.141592653589793238462643;
- const ll MOD = ll(1e9) + 7;
- #define pb push_back
- #define all(v) v.begin(), v.end()
- #define sz(v) v.size()
- #define x first
- #define y second
- #define watch(el) cout << #el << " " << el << endl;
- using namespace std;
- template<typename T> inline istream &operator >> (istream &in, vector<T> &v) { for (auto &i : v) { in >> i; } return in; }
- template<typename T> inline ostream &operator<< (ostream &out, const vector<T> &v) { for (auto &it : v) { out << it << " "; } return out; }
- 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; }
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- //ifstream cin("input.txt");
- //ofstream cout("output.txt");
- deque<string> q;
- int n;
- cin >> n;
- for (int i = 0; i < n; i++) {
- string cmd;
- cin >> cmd;
- if (cmd == "Run") {
- string s;
- getline(cin, s);
- s = s.substr(1, s.size() - 1);
- q.push_front(s);
- cout << s << endl;
- }
- else {
- int k = ((cmd.size() - 3) / 4)%q.size();
- for (int j = 0; j < k; j++) {
- string tmp = q.front();
- q.pop_front();
- q.push_back(tmp);
- }
- cout << q.front() << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement