I want to ask for help regarding my code for this problem in kattis.
https://open.kattis.com/problems/10kindsofpeople
When I tried to make the 'brr' array as a single dimension array it worked just fine. But when it is in a multi-dimension array, the program successfully runs, but it stops immediately. It won't even let me input. Can someone help me to find the problem?
#include <bits/stdc++.h>
using namespace std;
int r,c;
char arr[1005][1005];
void cari(int brr[][1005], int r1, int c1, int r2, int c2, bool &cek, char type){
if(r1 == r2 && c1 == c2){
if(type == arr[r2][c2]) cek = 1;
return;
}else if (r1 >= 1 && r1 <= r && c1 >= 1 && c1 <= c && type == arr[r1][c1] && brr[r1][c1] != 1){
brr[r1][c1] = 1;
cari(brr,r1-1, c1,r2,c2,cek,type);
cari(brr,r1,c1+1,r2,c2,cek,type);
cari(brr,r1,c1-1,r2,c2,cek,type);
cari(brr,r1+1,c1,r2,c2,cek,type);
}
}
int main (){
cin >> r >> c;
for(int i = 1; i <= r; i++){
string s;
cin >> s;
for(int j = 1; j <= c; j++){
arr[i][j] = s[j - 1];
}
}
int n;
cin >> n;
for(int i = 1; i <= n; i++){
int r1,c1,r2,c2;
int brr[1005][1005];
bool cek = 0;
cin >> r1 >> c1 >> r2 >> c2;
cari(brr,r1,c1,r2,c2,cek,arr[r1][c1]);
if(cek && arr[r1][c1] == '0') cout << "binary" << endl;
else if(cek && arr[r1][c1] == '1') cout << "decimal" << endl;
else cout << "neither" << endl;
}
}