XXCCN @ 2024-11-18 19:56:18
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
cin.ignore();
for (int i = 0; i < n; i++) {
string line;
getline(cin, line);
int flag = line[0] - '0';
if (flag == 1) {
string str1;
str1.assign(line, 2, line.size());
s += str1;
cout << s << endl;
} else if (flag == 2) {
int j = 2;
string strx = "";
string stry = "";
while (line[j] != ' ') {
strx += line[j];
j++;
}
while (j < line.size()) {
stry += line[j];
j++;
}
int a = stoi(strx);
int b = stoi(stry);
string str2;
str2.assign(s, a, b);
s = str2;
cout << s << endl;
} else if (flag == 3) {
int j = 2;
string strx = "";
string stry = "";
while (line[j] != ' ') {
strx += line[j];
j++;
}
j++;
while (j < line.size()) {
stry += line[j];
j++;
}
int x = stoi(strx);
s.insert(x, stry);
cout << s << endl;
} else if (flag == 4) {
string str4;
str4.assign(line, 2, line.size());
if (s.find(str4) != string::npos) {
cout << s.find(str4) << endl;
} else {
cout << -1 << endl;
}
}
}
return 0;
}