ROWCOLOP problem .Why is my code showing SIGSEGV error?

#include
#include
using namespace std;

int main() {
// your code goes here
int n,q;
cin>>n>>q;
long long int max=0;
int v[n][n];
for(int i=0;i<q;i++)
{
string s;
int a,b;
cin>>s>>a>>b;

    if(s=="ColAdd")
    {
        for(int j=0;j<n;j++)
        {
            v[a-1][j]=v[a-1][j]+b;
            
            if(v[a-1][j]>=max) max=v[a-1][j];
        }
        
    }
    else
    {
        for(int j=0;j<(n);j++)
        {
            v[j][a-1]=v[j][a-1]+b;
            
            if(v[j][a-1]>=max) max=v[j][a-1];
        }
    }
  
}
cout<<max<<endl;  

return 0;

}

You are allocating an array of dimensions n\times n. For the largest testcase, this turns out to be 314159^2 \times \text{sizeof int} \sim 367\ \text{gigabytes}. Memory limit is usually around 256 megabytes, orders of magnitude lower than what you are trying to allocate.

Try thinking of a different solution which takes, say O(n) space.

Also, provide a submission link and the problem link in your post instead of copy pasting your code.