### Saratov State University :: Online Contester

::Go
- home
- news
- register
 - update personal info
 - problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- projects

 ::Poll Are you registered on Codeforces?YesNoWhat is it???[results]

::webboard

 Time Limit, Whyyyyy???
Author: Vahidenstein
ID: 049588
Problem: 271
Contest: 0
Date: 2012-02-13 16:55:50

Somebody help me, I've got time limit...
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int n, m, k;
vector <string> ans;
vector <string> vec;
void rotate(){
int o=k;
if (k>ans.size()) o=ans.size();
for (int i=ans.size()-o;i<ans.size();i++)
vec.push_back(ans[i]);
for (int j=0;j<o;j++)
ans.pop_back();
for (int h=vec.size()-1;h>=0;h--){
ans.push_back(vec[h]);
vec.pop_back();
}
}
void input(){
cin >> n >> m >> k;
for (int i=0;i<n;i++){
string s;
cin >> s;
vec.push_back(s);
}
for (int j=vec.size()-1;j>=0;j--){
ans.push_back(vec[j]);
vec.pop_back();
}
for (int h=0;h<m;h++){
string s;
cin >> s;
if (s[0]=='A') ans.push_back(s);
else rotate();
}
}

int main(){
input();
for (int i=ans.size()-1;i>=0;i--){
if (ans[i].length()>3){
for (int j=4;j<ans[i].length()-1;j++)
cout << ans[i][j];
cout << endl;
}
else cout << ans[i] << endl;
}
return 0;
}