Xorry Queries

Sort by

recency

|

8 Discussions

|

  • + 0 comments

    The definition of the problem is wrong.

    Definition says,

    sum(l...r) = p(l) + p(l+1) + ... + p(r)
    

    But the implementation works when,

    sumfunc(l...r) = p(l) + p(l+1) + ... + p(r-1)
    

    Here the interval [l,r) is left-closed,right-opened.

  • + 0 comments

    what is wrong with this??

    include

    using namespace std; int main() { int n,i,m,l,k,j,p,x,sum=0; cin>>n>>m>>p; int a[n];

    for(i=1;i<=n;i++) { cin>>a[i]; } for(i=1;i<=m;i++) { cin>>j>>k>>l; if(j==1) { a[k]=a[k]^l;

     }
     if(j==2)
     {
        for(x=k;x<=l;x++)
        {
    
            if(x+p-2<n)
            {
    
                a[x]=a[x]^a[x+1];
                sum+=a[x];
            }
            else
                a[x]=0;
        }
     }
    

    }

    cout<

    }

  • + 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 ;
        
    }
    
  • + 1 comment

    Can you tell if there are any pre-requisites to the problem?

  • + 0 comments

    The contest has ended! I am unable to debug my code, to where it is going wrong. I am getting 2 testcases correct. Can someone post sample test cases?