Can any one please tell me where am i going wrong in this question. Question name- Tom And Jerry 1

#include
using namespace std;

int main() {
int t;
cin>>t;
while(t–){
int a,b,c,d,k;
cin>>a>>b>>c>>d>>k;
int l=(abs(a-c) + abs(b-d));
if (k%2==0){
if ((l-k)%2==0)
cout<<“YES”<<endl;
else
cout<<“NO”<<endl;
}
else{
if ((l-k)%2==0)
cout<<“YES”<<endl;
else
cout<<“NO”<<endl;

    }
}
return 0;

}

Assume a case where (a,b) is (1,1) and (c,d) is (1,9) and k = 2. So here, l = 8 and k = 2. Thus such cases will always give NO as the output but in your code these are also getting accepted and you’re getting a YES. So the if-else conditions that you’ve used are incorrect.

1 Like

ooh , now i understood where i was wrong. Thanks bro.

You’re Welcome