Miracle516 @ 2024-11-16 00:36:47
好像是个经典错误了
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
int n;
scanf("%d",&n);
getchar();
string s;
getline(cin,s);
while(n--){
string c;
getline(cin,c);
if(c[0]=='1'){
for(int i=2;i<c.length();i++)s+=c[i];
cout<<s<<endl;
}else if(c[0]=='2'){
int t;
string id="",a="",r="";
for(int i=2;c[i]!=' ';i++)id+=c[i],t=i;
for(int i=t+2;i<c.length();i++)a+=c[i];
int c=stoi(id),d=stoi(a);
for(int i=c;i<c+d;i++)r+=s[i];
s=r;
cout<<s<<endl;
}else if(c[0]=='3'){
int t;
string id="",a="";
for(int i=2;c[i]!=' ';i++)id+=c[i],t=i;
for(int i=t+2;i<c.length();i++)a+=c[i];
s.insert(stoi(id),a);
cout<<s<<endl;
}else if(c[0]=='4'){
string id="";
for(int i=2;i<c.length();i++)id+=c[i];
if(s.find(id)==string::npos) cout<<-1<<endl;
else cout<<s.find(id)<<endl;
}
}
return 0;
}