#include
using namespace std;
int main()
{
int T;
cin>>T;
string s[T];int N[T],M[T];
for(int i=0;i<T;i++)
{
cin>>s[i];cin>>N[i]>>M[i];
}
for(int i=0;i<T;i++)
{
for(int j=N[i];j<M[T];j++)
{
string s1=s[i].substr(j,1);string s2=s[i].substr(j+1,1);
if(s1.compare(s2)==-1){s[i].erase(j+1,1);s[i].insert(j,s2);}
}
}
for(int i=0;i<T;i++)
{
cout<<endl<<s[i];
}
return 0;
}
Idk what is the question but M[T] should be M[i] I guess(in condition of for loop)… If not… share the question link.
You are getting SIGABART because the value of M[T] goes beyond the string length and hence you cant compute substring of the string. In some Compilers, M[T] would be 0 by default. I checked on Codechef’s Compiler it was random more than 32K and in your test case string length would be less, hence SIGABART. (Out of range). Mostly, instead of M[T], it would be M[i]. Just make sure N[i], M[i] it doesn’t go beyond String length(s[i].size()).
thanku it should have been M[i]