My logic is that
if(nm) is even then all the freq of distinct element must be even
else if(nm is odd) then count the elements having odd freq and if we have more than 1 count
i,e, we have more than 2 elements having odd freq then print -1
else normally solve.
. Can you please check my solution why it gives WA
My solution
Please help me and tell me where I am doing mistake
Here a case for which your code is not working.
1
1 1
10
P.S. Pay attention to 1 \le A_{i,j} \le 10^5.
https://www.codechef.com/viewsolution/33366171
It added the base condition still gives WA,
IS THIS LOGIC IS CORRECT FOR CHECKING i.e., NOT POSSIBLE TO IMPRESS CHEFINA??
if(n*m) is even then all the freq of distinct element must be even
else if(n m is odd) then count the elements having odd freq and if we have more than 1 count
i,e, we have more than 2 elements having odd freq then print -1