#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main(){
int q;
freopen("../input.txt", "r", stdin);
//在洛谷里去掉这句
string word;
cin>>q>>word;
getchar();
getchar();
for(int i=0;i<q;i++){
string line;
char mode;
mode=getchar();
if(mode == '1'){
string str;
cin>>str;
word+=str;
cout<<word<<'\n';
}
else if(mode == '2'){
int index,num;
cin>>index>>num;
word=word.substr(index,num);
cout<<word<<'\n';
}
else if(mode == '3'){
string str;
int index;
cin>>index>>str;
word=word.substr(0,index)+str+word.substr(index,word.size());
cout<<word<<'\n';
}
else{
string str;
cin>>str;
if(strstr(word.c_str(),str.c_str())!=NULL)
cout<<strstr(word.c_str(),str.c_str())-word.c_str()<<'\n';
else cout<<-1<<'\n';
}
getchar();
getchar();
}
return 0;
}
以上这段代码,在clion里,按样例输入保存到input.txt里,输出四个-1 而在洛谷在线IDE和提交题里,这段代码就AC. 希望大家能够解惑