using try-catch block, I determined that this section of code triggered a bad alloc exception
for(int i = 0;i<n;i++){
for(int j = 0;i<t.length()-subs[i].length()+1;j++){
if(subs[i]==t.substr(i,subs[i].length())){
st cur;
cur.type = i+1;
cur.a = j;
cur.b = j+subs[i].length()-1;
intervals.push_back(cur);
}
}
}
For references, here is the full problem I am working on: Problem - 1714D - Codeforces
The sturct st only contains three ints and a bool operator. intervals is a vector of st.