Help me in solving SUB_XOR problem

My issue

My code

#include <iostream>
#include<bits/stdc++.h>
// #define int long long int
using namespace std;
#define mod 908244353

int main() {
    int t;
    cin>>t;
    while(t--)
    {
  long long int n;
    cin>>n;
    string s;
    cin>>s;
    vector<long long int>a(n);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        a[n-i-1]+=i+1;
    }
    for(int i=n-2;i>=0;i--)
    {
        a[i]+=a[i+1];
    }
  long long  int ans=0;
  long long  int cur=1;
    for(int i=0;i<n;i++)
    {
        if(a[i]%2)
        {
          ans=(ans+cur)%mod;  
        }
         cur=(cur*2)%mod;
    }
    cout<<ans<<endl;
    }
	return 0;
}

Problem Link: SUB_XOR Problem - CodeChef

@neelakshi12
i think the logic is not right.
think of it in a way like contribution of each bit in all substring like 101 contribution of 2^0 will be two times , 2^1 one time ,2^2 one time so if the contribution is odd times add it in your answer.