Help me in solving PARPER problem

My issue

what is wrong int this code ,plz explain…

My code

``````#include <bits/stdc++.h>
#define ll int long long
using namespace std;
int const mod=1e9+7;

int main() {
ll t;
cin>>t;
while(t--){
ll n,k;
cin>>n>>k;
vector<ll>a(n);
for(ll i=0;i<n;i++){cin>>a[i];}

vector<ll>fac(n+1);
fac[0]=1;
fac[1]=1;
for(ll i=2;i<=n;i++){
(fac[i]=i*fac[i-1])%=mod;
}
ll odd=0,even=0;
for(ll i=0;i<n;i++){
if(a[i]%2) odd++;
else even++;
}
if(k==0){
if(odd==n || even==n){
cout<<(fac[n]%mod)<<endl;
}
else cout<<0<<endl;
}
if(k==1){
if(odd==even){
ll ans=1;
(ans*=fac[odd])%=mod;
(ans*=fac[even])%=mod;
(ans*=2)%=mod;
cout<<ans<<endl;
}

if(odd > even ) swap(odd,even);
if(odd+1==even){
ll ans=1;
(ans*=fac[odd])%=mod;
(ans*=fac[even])%=mod;
cout<<ans<<endl;
}
else cout<<0<<endl;

}
}
return 0;
}

``````

Problem Link: PARPER Problem - CodeChef

@deepakjdh31
For test case
1
2 1
2 23
2
0
and the output should be only
2

In the code block if(k==1){…}, if (odd==even) holds true, it will print the answer. Further it will move to else statement and print 0 as well. This extra 0 is causing the issue.

Try the test case:

1
6 1
1 2 3 4 5 6

Expected O/P :
72