#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<char>a(n);
for (auto &i : a)
{
cin >> i;
}
while (m--)
{
char x;
cin >> x;
if (x == 'a')
{
int i, j;
cin >> i >> j;
i--;
j--;
char p = a[i];
if (j != i)
{
a.erase(a.begin() + i);
if (j < i)
{
a.emplace(a.begin() + j, p);
}
else
{
a.emplace(a.begin() + j, p);
}
}
}
if (x == 'q')
{
int q;
cin >> q;
cout << a[q - 1] << endl;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
8 ms |
396 KB |
Output is correct |
3 |
Correct |
20 ms |
440 KB |
Output is correct |
4 |
Correct |
141 ms |
1828 KB |
Output is correct |
5 |
Correct |
273 ms |
2084 KB |
Output is correct |
6 |
Correct |
309 ms |
2236 KB |
Output is correct |
7 |
Correct |
354 ms |
2404 KB |
Output is correct |
8 |
Correct |
177 ms |
2280 KB |
Output is correct |
9 |
Correct |
417 ms |
2400 KB |
Output is correct |
10 |
Correct |
310 ms |
2376 KB |
Output is correct |