# https://www.codechef.com/COOK126B/problems/MINIL

https://www.codechef.com/COOK126B/problems/MINIL
can someone tell me why this is giving wrong answer
#include
#include
#include
using namespace std;
int main(){
int t,n,m;
cin>>t;
while(t–){
cin>>n>>m;
int s[n][m],p[n][m],q[n][m];
char ch;
//using 1 for * and 0 for .
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>ch;
if(ch==’*’)
s[i][j]=1;
else
s[i][j]=0;
}
}
//creating two arrays in which horizontal and
// vertical adj cell different element
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(i%2==0){
if(j%2==0){
p[i][j]=1;
q[i][j]=0;
}
else{
p[i][j]=0;
q[i][j]=1;
}
}
else{
if(j%2==0){
p[i][j]=0;
q[i][j]=1;
}
else{
p[i][j]=1;
q[i][j]=0;
}
}
}
}
//check in both the possible case
//how many position are different in given
//maximum possible island, output minimum
int c1=0,c2=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(s[i][j]!=p[i][j])
c1++;
if(s[i][j]!=q[i][j])
c2++;
}
}
cout<<min(c1,c2)<<endl;
}
}

I did exactly the same mistake as you did, but soon realised what I was missing.
Ex:
Input:
.*.

Correct output: 3