Runtime Error:Segmentation fault 一直出现这个给我整麻了 求解求解

一直出现这个 整的我快麻了
Runtime Error:Segmentation fault
题目是

img

代码

#include <stdio.h>
#include <string.h>
int a[22335][22335];
int main(void)
{
    int n,m,x,y,i,j;
    while(scanf("%d %d %d %d",&n,&m,&x,&y)!=EOF)
    {
    
    int c=n*m;
    int flag=0;
    a[0][0]=1;
    int q=0,p=1;
    a[0][1]=2;
    int count=3;
    while(count<c)
    {
        
        
        while(q+1<n&&p-1<m&&q+1>=0&&p-1>=0)
        {
            a[q+1][p-1]=count;
            q=q+1;
            p=p-1;
            count++;
        }
    

        if(q+1<n)
        {
            a[q+1][p]=count;
            count++;
            q=q+1;
        
        }
        else if(p+1<m) 
        {
            a[q][p+1]=count;
            count++;
            p=p+1;
        
        }
    
    
        while(q-1>=0&&p+1<m)
        {
            a[q-1][p+1]=count;
            count++;
            q=q-1;
            p=p+1;
        }
        if(p+1<m)
        {
            a[q][p+1]=count;
            count++;
            p=p+1;
        }
        else if(q+1<n)
        {
            a[q+1][p]=count;
            count++;
            q=q+1;
        }
     
    
    
   
    
    }

    printf("%d\n",a[x][y]);
}


    
} 

int a[22335][22335];
申请空间太大了,申请不到的。你怎么会要这么大的数组呢,根据实际需要申请吧