题目传送门
#include <bits/stdc++.h>
using namespace std;
string s, a;
int n;
int opt;
int l, cnt;
int main() {
cin >> n >> s;
while (n--) {
cin >> opt;
switch (opt) {
case 1:
cin >> a;
s.append(a);
printf("%s\n", s.c_str());
break;
case 2:
cin >> l >> cnt;
s = s.substr(l, cnt);
printf("%s\n", s.c_str());
break;
case 3:
cin >> l >> a;
s.insert(l, a);
printf("%s\n", s.c_str());
break;
case 4:
cin >> a;
auto pos = s.find(a);
if (pos != s.npos) printf("%d\n", pos);
else printf("%d\n", -1);
break;
}
}
return 0;
}