Why do I get a SIGSEGV?

I get “Access Denied” for that link.

I cleared the doubt. Thanks though

Really saved me. The thing to really check for is that you don’t store 1e7 memory in the main function itself! Thanks!

You have not declared vik vector.

You declared j but never used it , that’s why I think you’re getting runtime error

Thanks, great tips for solving the error I was running into

#include <iostream>
#include <cmath>
using namespace std;

int main() {
	int t;
	cin >> t;
	while (t--)
	{
	    int d;
	    cin >> d;
	    string s;
	    cin >> s;
	    int days;
	    int count_p=0;
	    for (int i=0;i<d;i++)
	    {
	        if (s[i]=='P')
	        {
	            count_p++;
	        }
	        
	    }
	    float req=0.75*d;
	    if (count_p>=req)
	    {
	        cout << '0' << endl;
	        break;
	    }
	    else
	    {
	        if (fmod(req,float(1))==0)
	        {
	            days=req-count_p;
	        }
	        else
	        {
	            days=1+(req-count_p);
	        }
	        
	    }
	    int count=days;
	    for (int j=2;(days!=0 || j<d-2);j++)
	    {
	        if (s[j]=='A')
	        {
	            if ((s[j-1]=='P' || s[j-2]=='P')&&(s[j+1]=='P' || s[j+2]=='P'))
	            {
	                s[j]='P';
	                days--;
	            }
	        }
	    }
	    if (days==0)
	    {
	        cout << count;
	    }
	    else
	    {
	        cout << "-1";
	    }
	    
	}
}

Why am i getting SIGSEGV Error??