Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
- int main()
- {
- fast()
- ll t;
- cin>>t;
- while(t--)
- {
- ll n;
- cin>>n;
- ll ara[n+1],i;
- for(i=0;i<n;i++)cin>>ara[i];
- ll wo=0,we=0;
- for(i=0;i<n;i++)
- {
- if(i%2==0 && ara[i]%2!=0)we++;
- if(i%2==1 && ara[i]%2!=1)wo++;
- }
- if(we==wo)cout<<we<<endl;
- else cout<<"-1"<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement