# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
573203 | SSRS | Collider (IZhO11_collider) | C++14 | 170 ms | 4384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int B = 1000;
int main(){
int n, m;
cin >> n >> m;
string s;
cin >> s;
int cnt = (n + B - 1) / B;
vector<string> t(cnt);
for (int i = 0; i < n; i++){
t[i / B] += s[i];
}
for (int i = 0; i < m; i++){
char c;
cin >> c;
if (c == 'a'){
int x, y;
cin >> x >> y;
x--;
y--;
char p;
for (int j = 0; j < cnt; j++){
if (x < t[j].size()){
p = t[j][x];
t[j].erase(t[j].begin() + x);
break;
}
x -= t[j].size();
}
for (int j = 0; j < cnt; j++){
if (y <= t[j].size()){
t[j].insert(t[j].begin() + y, p);
break;
}
y -= t[j].size();
}
}
if (c == 'q'){
int x;
cin >> x;
x--;
for (int j = 0; j < cnt; j++){
if (x < t[j].size()){
cout << t[j][x] << endl;
break;
}
x -= t[j].size();
}
}
if (i % B == B - 1){
s.clear();
for (int j = 0; j < cnt; j++){
s += t[j];
t[j].clear();
}
for (int j = 0; j < n; j++){
t[j / B] += s[j];
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |