Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://codeforces.com/contest/1101/problem/G
- #include<bits/stdc++.h>
- using namespace std;
- #define MAX 200005
- #define ll long long
- ll a[MAX];
- vector<bitset<64> >v;
- ll gauss(int n,int m)
- {
- int col=m-1,row=0,i,j;
- ll ans=0;
- for(;col>=0 && row<n;col--){
- for(i=row;i<n;i++){
- if(v[i][col]){
- swap(v[i],v[row]);
- break;
- }
- }
- if(!v[row][col])continue;
- for(i=0;i<n;i++){
- if(i==row)continue;
- if(v[i][col])
- v[i]^=v[row];
- }
- row++;
- }
- return row;
- }
- int main()
- {
- //freopen("input.txt","r",stdin);
- int i,j,n;
- ll xx=0;
- scanf("%d",&n);
- for(i=0;i<n;i++){
- scanf("%lld",&a[i]);
- xx^=a[i];
- }
- if(xx==0)return cout<<-1<<endl,0;
- for(i=0;i<n;i++){
- bitset<64>x;
- for(j=0;j<64;j++){
- if(a[i] & (1LL<<j))x[j]=1;
- else x[j]=0;
- }
- v.push_back(x);
- }
- ll ans=gauss(n,64);
- cout<<ans<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement