What is wrong in this


#1

has cleared all trivial cases failed in real test case

int ans(int i,int A, vector<vector >& B, int& to,vector& v,int& w){
v[i-1] = 1;
int n = 1;
for(auto x :B){
if(x[0]==i){
if(v[x[1]-1]==0){
n = n+ans(x[1],A,B,to,v,w);
}
}
else if(x[1]==i){
if(v[x[0]-1]==0){
n = n+ans(x[0],A,B,to,v,w);
}
}
}
if(n%2==0&&i!=w){
to++;
return 0;
}
return n;
}
int Solution::solve(int A, vector<vector > &B) {
int to = 0;
vector v(A,0);
for(int i =1;i<=A;i++){
if(v[i-1]==0){
ans(i,A,B,to,v,i);
}
}
return to;
}