[SIGABRT] - Why am I getting a SIGABRT error in this code ?

Here’s the link - https://www.codechef.com/problems/STRBIT

THANKS IN ADVANCE !!!

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
int t;cin>>t;
while(t--){
	int n,k;cin>>n>>k;
	char s[100001];scanf("%s" , s);
	int ans=0,flip =0;
	vector<int> mark(n*2+1);
	for(int i=0;i<n;i++){
		flip+=mark[i];
		if((s[i]=='R' && (flip%2)==0) || (s[i]=='G' && (flip%2)==1))
		{
			mark[i+1]++;
			mark[i+k]--;
			ans++;
		}
	}
	cout<<ans<<endl;
}
return 0;
}

Though I have not read the question, your solution gives sigabrt error due to memory allocation. The stacks becomes full because you allocate a lot of memory (declaring large size vector and char array for every test case). Instead, you should do it like this https://www.codechef.com/viewsolution/9010528 this is your solution, just modified the declaration part, though it gives wrong answer. :frowning:

//