#include <bits/stdc++.h>
using namespace std;
string s;
int n, m, bs = 1000;
vector < int > v[10003];
main () {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
cin >> n >> m >> s;
for (int i = 0; i < n; ++i) {
v[i / bs].push_back(i);
}
int ms = (n - 1) / bs + 1;
for (int i = 1; i <= m; ++i) {
char c;
cin >> c;
if (c == 'a') {
int id = 0, l, r;
cin >> l >> r; --l, --r;
if (l < r) --r;
for (int b = 0; b < ms; ++b) {
if (v[b].size() <= l) {
l -= v[b].size();
}
else {
id = v[b][l];
v[b].erase(v[b].begin() + l);
break;
}
}
for (int b = 0; b < ms; ++b) {
if (v[b].size() < r) {
r -= v[b].size();
}
else {
v[b].insert(v[b].begin() + r, id);
break;
}
}
}
else
if (c == 'q') {
int x;
cin >> x; --x;
for (int b = 0; b < ms; ++b) {
if (v[b].size() <= x) {
x -= v[b].size();
}
else {
cout << s[v[b][x]] << "\n";
break;
}
}
}
if (i % bs == 0) {
vector < int > rec;
for (int b = 0; b < ms; ++b) {
for (int j = 0; j < v[b].size(); ++j) {
rec.push_back(v[b][j]);
}
v[b].clear();
}
for (int j = 0; j < rec.size(); ++j) {
v[j / bs].push_back(rec[j]);
}
rec.clear();
}
}
}
Compilation message
collider.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main () {
| ^~~~
collider.cpp: In function 'int main()':
collider.cpp:26:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
26 | if (v[b].size() <= l) {
| ~~~~~~~~~~~~^~~~
collider.cpp:37:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | if (v[b].size() < r) {
| ~~~~~~~~~~~~^~~
collider.cpp:51:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
51 | if (v[b].size() <= x) {
| ~~~~~~~~~~~~^~~~
collider.cpp:64:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for (int j = 0; j < v[b].size(); ++j) {
| ~~^~~~~~~~~~~~~
collider.cpp:69:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for (int j = 0; j < rec.size(); ++j) {
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |