Saratov State University :: Online Contester


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

::Poll
Are you registered on Codeforces?
Yes
No
What 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;
}





see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-11-24 14:08:12Online Contester Team © 2002 - 2016. All rights reserved.