#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("fast-math")
#pragma GCC optimize ("unroll-loops")
using namespace std;
#define int long long
#define ll long long
#define all (x) begin(x), end (x)
#define xx first
#define yy second
using pii = pair <int, int>;
using tii = tuple <int, int, int>;
int n, m;
string s;
int x, y;
signed main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
cin >> s;
for (int i = 0; i < m; ++ i)
{
char op;
cin >> op >> x;
x = x - 1;
if (op == 'a')
{
cin >> y;
y = y - 1;
char ch = s[x];
s.erase (s.begin() + x);
s.insert (s.begin() + y, ch);
}
else
cout << s[x] << '\n';
}
return 0 ^ 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |