Codeblocks Error when starting the program 0xc00000fd

I wrote a three-dimensional Fenwick tree in c++, I run the program, it crashes with the error code 0xc00000fd, here is the code:

#include <bits/stdc++.h>

using namespace std;
#define MAXN 210
long long n,x1,y_1,z1,x2,y2,z2,q,k,a[MAXN][MAXN][MAXN],oper;
struct Fenwick
{
    long long t[MAXN][MAXN][MAXN];
    void buildT()
    {
        for(int i=1; i<=MAXN; i++)
            for(int j=1; j<=MAXN; j++)
                for(int u=1; u<=MAXN; u++)
                    t[i][j][u]=1;
    }

    void add(long long x,long long y,long long z,long long value)
    {
        x++;
        y++;
        z++;
        a[x][y][z]+=value;
        for(long long i=x; i<MAXN; i+=(i & -i))
            for(long long j=y; j<MAXN; j+=(j & -j))
                for(long long u=z; u<MAXN; u+=(u & -u))
                    t[i][j][u]+=value;

    }
    long long sumpref3d(long long x,long long y,long long z)
    {
        x++;
        y++;
        z++;

        long long sum=0;

        for(long long i=x; i>0; i-=(i & -i))
            for(long long j=y; j>0; j-=(j & -j))
                for(long long u=z; u>0; u-=(u & -u))
                    sum+=t[i][j][u];
        return sum;
    }
    long long sumpara(long long x1,long long y1,long long z1,long long x2,long long y2,long long z2)
    {
        return sumpref3d(x1,y1,z1)-
               sumpref3d(x1,y1,z2-1)-
               sumpref3d(x1,y2-1,z1)-
               sumpref3d(x2-1,y1,z1)+
               sumpref3d(x1,y2-1,x2-1)+
               sumpref3d(x2-1,y1,z2-1)+
               sumpref3d(x2-1,y2-1,z1)-
               sumpref3d(x2-1,y2-1,z2-1);
    }
    void changeValue(long long x,long long y,long long z,long long k)
    {
        add(x,y,z,k);
    }
};
int main()
{
    Fenwick fenwick;
    fenwick.buildT();
    scanf("%lld",&n);
    while(true)
    {
        scanf("%lld ", &oper);
        if(oper==3)break;
        else if(oper==1)
        {
            scanf("%lld %lld %lld %lld\n",&x1,&y_1,&z1,&k);
            fenwick.changeValue(x1,y_1,z1,k);
        }
        else if(oper==2)
        {
            scanf("%lld %lld %lld %lld %lld %lld\n",&x1,&y_1,&z1,&x2,&y2,&z2);
            printf("%lld\n",fenwick.sumpara(x1,y_1,z1,x2,y2,z2));
        }

    }



}
Author: Harry, 2017-07-18

1 answers

It is unlikely that you have such a large stack that you can withstand an array of 9261000 elements of 8 bytes-a total of more than 70 megabytes...

Allocate such large arrays dynamically.

In addition, you forget that arrays are indexed starting from zero, and you get out of their bounds - for example, here:

for(int i=1; i<=MAXN; i++)
    for(int j=1; j<=MAXN; j++)
        for(int u=1; u<=MAXN; u++)
            t[i][j][u]=1;

Then I did not look at the correctness of the code.

 3
Author: Harry, 2017-07-18 13:54:05