Xorry Queries

  • + 0 comments

    whats wrong here ???

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        int n,m,p;
        cin>>n>>m>>p;
        int arr[n];
         int sum = 0, res = 0 ;
        for(int i = 1 ;i<= n;i++)
        {
            cin>>arr[i] ;
        }
            while(m--)
       {
           int q;
           int l;
           int r ;
        cin>>q>>l>>r;
                if(q == 1)
                {
                    arr[l] = arr[l] ^ r;
                    // for(int i = 1 ; i<= n ;i++)
                    //     cout<<arr[i]<<" ";
                }
                else
                { 
                   
                    for(int i = l ; i<=r ; i++)
                    {
                        if(i+p-1 <= n)
                        {
                            sum = arr[i] ^ arr[i+1] ;
                            res=res + sum ;
                        }
                    }
                               cout<<res<<endl;
    
                }
       }
    
        return 0 ;
        
    }