0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 02:18:51 +00:00
OI-codes/Luogu/P5734/P5734.cpp

44 lines
923 B
C++
Raw Normal View History

// https://www.luogu.com.cn/record/35887921
2021-11-19 09:01:13 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n = 0;
cin >> n;
string s = "";
cin >> s;
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
int act;
cin >> act;
if (act == 1) {
string s1;
cin >> s1;
s += s1;
cout << s;
2021-11-19 09:01:13 +00:00
} else if (act == 2) {
int st, ed;
cin >> st >> ed;
s = s.substr(st, ed);
cout << s;
2021-11-19 09:01:13 +00:00
} else if (act == 3) {
int st;
string s1;
cin >> st >> s1;
s.insert(st, s1);
cout << s;
2021-11-19 09:01:13 +00:00
} else if (act == 4) {
string s1;
cin >> s1;
2021-11-19 09:01:13 +00:00
if (s.find(s1) < s.size()) {
cout << s.find(s1);
2021-11-19 09:01:13 +00:00
} else {
cout << "-1";
}
}
cout << endl;
}
return 0;
}