Wrong ans in one test case

#include
using namespace std;

int main() {
int n,m;
cin>>n>>m;
int a[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>a[i][j];
}
}
int x;
cin>>x;
int r=0,c=m-1;
if(n==0&&m==0){
cout<<“0”;
return 1;
}
if(x<a[0][0]&& x>a[n-1][m-1]){
cout<<“0”;
return 1;
}
int count=0;
while(r<n && c>=0){
if(x>a[r][c]){
r++;
}else if(x<a[r][c]){
c–;
}else if(a[r][c]==x){
count=1;
break;
}
}
if(count==0){
cout<<“0”;
}else{
cout<<“1”;
}
return 0;
}

hi @umnah1103_2205d5eee7973385
Try this-

@umnah1103_2205d5eee7973385
is there anything else or shall I mark the doubt as resolved??

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.