Submission #549832

# Submission time Handle Problem Language Result Execution time Memory
549832 2022-04-16T15:35:26 Z Vovamatrix XORanges (eJOI19_xoranges) C++14
0 / 100
96 ms 9924 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define endl "\n"

#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
#define MAXN 200007

void update(vector<ll>& v, ll k, ll x)
{
    while(k<v.size())
    {
        v[k]+=x;
        k+=k&-k;
    }
}
ll prefsum1(const vector<ll>& v, ll k)
{
    ll sum=0;
    while(k>0)
    {
        sum^=v[k];
        k-=k&-k;
    }
    return sum;
}
ll prefsum2(const vector<ll>& v, ll k)
{
    ll sum=0;
    while(k>0)
    {
        sum+=v[k];
        k-=k&-k;
    }
    return sum;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,q; cin>>n>>q;
    vector<ll> BIT2(n+1,0),BIT3(n+1,0);
    for(int i=1;i<=n;i++)
    {
        ll x; cin>>x;
        if(i%2==0) update(BIT2, i, x);
        else update(BIT3, i, x);
    }
    for(int i=1;i<=q;i++)
    {
        ll x,y,z; cin>>x>>y>>z;
        if(x==2)
        {
            if((z-y+1)%2==0) cout<<0<<endl;
            else
            {
                if(y%2==0) cout<<((prefsum1(BIT2, z))^(prefsum1(BIT2, y-1)))<<endl;
                else cout<<((prefsum1(BIT3, z))^(prefsum1(BIT3, y-1)))<<endl;
            }
        }
        else
        {
            if(y%2==0) update(BIT2, y, z-(prefsum2(BIT2, y)-prefsum2(BIT2, y-1)));
            else update(BIT3, y, z-(prefsum2(BIT3, y)-prefsum2(BIT3, y-1)));
        }
        /*if(i==2) //debug
        {
            cout<<prefsum2(BIT3, 1)-prefsum2(BIT3, 1-1)<<" "<<prefsum2(BIT3, 2)-prefsum2(BIT3, 2-1)<<" "<<prefsum2(BIT3, 3)-prefsum2(BIT3, 3-1)<<" "<<prefsum2(BIT3, 4)-prefsum2(BIT3, 4-1)<<" "<<prefsum2(BIT3, 5)-prefsum2(BIT3, 5-1)<<endl;
            cout<<prefsum1(BIT2, 5)<<" "<<prefsum1(BIT3, 0)<<endl;
        }*/
    }
    return 0;
}

Compilation message

xoranges.cpp: In function 'void update(std::vector<long long int>&, long long int, long long int)':
xoranges.cpp:23:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     while(k<v.size())
      |           ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 9924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -