XOR ZERO

#include<bits/stdc++.h> #define ll long long using namespace std; typedef vector<long long> vl; #define all(v) (v).begin(),(v).end() #define pb push_back #define tr(v,it) for(auto it=(v).begin();it!=(v).end();it++) #define mod 1000000007 int main() { ll t,n,x,z,o,s; cin>>t; while(t--) { cin>>n; o=0; z=0; cin>>s; if(s) o++; else z++; cin>>x; if(x) o++; else z++; s=s^x; //cout<<"s="<<s<<endl; n=n-2; while(n--) { cin>>x; if(x) o++; else z++; s=s^x; } if(s) cout<<o<<endl; else cout<<z<<endl; } return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.