Segment error occurred in CPP submission

There is a water word in the first line of

. Starting from the second line, replace the water on the previous line with the water question, which is listed as follows:

Water
Water questions
Water questions
input multiple sets of data, one line for each group of data.
there are two numbers in each row. For each set of data, find out whether the words in n rows and k columns are "water" or "problem". If it is water, output 0; if it is a question, output 1.
wants to use 0 instead of water and 1 generation instead of water, and report a paragraph error after submission, but it is no problem to compile and run it by itself. I should be a novice. Save the child.

the code is as follows

include < iostream >
using namespace std;
int main () {

int i,j,n,k,a[20][20];
while(cin>>n>>k){
    a[0][0]=0;
    for(i=1;i<n;iPP){
        for(j=0;j<n;jPP){
            if(a[i-1][j-1]==0){
                a[i][j]=0;
                a[i+1][j+1]=1;
            }
            if(a[i-1][j-1]==1){
                a[i][j]=1;
                a[i+1][j+1]=0;
            }
        }            
    }
    cout<<a[n][k]<<endl;
}
return 0;

}

CPP
Apr.21,2022
When

brushes OJ, the segment error is almost always caused by the small definition of the array , or the array subscript is out of bounds. Check carefully to see if the range of n and k is specified in the title. If not emphasized, then you need to use vector, malloc processing, or directly to a violent approach: directly open the array to the 2000 dimension, pay attention to this to define the array as global.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5ef6a-457e1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5ef6a-457e1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?