Playing With BITs

Limits: 1s, 512 MB

Little boy Tom recently learnt about BIT operation. And he is interested in it. So he himself plays the game with BITs. Seeing this, great programmer Jerry give him a task. Initially, Jerry gives an array with N numbers and Q queries.


This is a companion discussion topic for the original entry at https://toph.co/p/playing-with-bits

@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;
}