Playing With BITs

Little boy Tom recently learnt about BIT operation. And he is interested in it. So he himself plays …

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

@hjr265 why this submission is not being AC? While I have seen a submission with almost the same code as me and that got accepted!

#include <bits/stdc++.h>
#define ll long long 
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    ll q;
    cin>>q;
    while(q--){
        ll k;
        cin>>k;
        if(k==1){
            ll a,x;
            cin>>a>>x;
            v[a-1]=x;
        }
        else{
            ll l,r,c;
            cin>>l>>r>>c;
            ll co=0;
            for(int i=l-1;i<r;i++){
				if(v[i]&(1<<c)) co++;
            }
            cout<<co<<endl;
        }
    }
	return 0;
}