#include
#include
#include
using namespace std;
int main ()
{
int t;
cin >> t;
while (t–)
{ int n,K;
cin>>n>>K;
char *s=new char[n];
for(int i=0;i<n;i++){
cin>>s[i];
}
int *p=nullptr,*q=nullptr,countans=0;
int i, j = 0, pw, x, y;int count=0;
for (i = 0; i < strlen(s); i++)
{
if (s[i] == ‘X’)
{
p=0,q=0;
}
if(s[i]== ‘M’){
p=&i;
}
if(s[i]==‘I’){
q=&i;
}
if(p || q){
if(s[i]==’:’){
count++;
}
}
if(p && q){
pw = (K + 1) - abs(*p-*q) - count;
if(pw>0){
p=q=0;count=0;
countans++;
}
else{
p=q=0;
count=0;
}
}
}
cout << countans<<endl;
delete []s;
}
return 0;
}
what’s the error??