Submission #999720

# Submission time Handle Problem Language Result Execution time Memory
999720 2024-06-16T05:49:46 Z vjudge1 XORanges (eJOI19_xoranges) C++17
0 / 100
25 ms 10036 KB
#include <bits/stdc++.h>
// author : Pluton
#define OPT         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int         ll
#define ll          long long
#define pb          push_back
#define arr         array
#define fi          first
#define se          second
#define rep(i,j,k)  for(int i = j; i <= k; ++i)
#define all(a)      a.begin(),a.end()
#define pii         pair<int,int>
using namespace std;
const int INF = 1e18;

struct BIT
{
    int n;
    vector<int> ft;
    void init(int N)
    {
        n = N + 5;
        ft.assign(n + 5, 0);
    }
    void add(int pos, int val)
    {
        for (pos = pos + 1; pos <= n; pos += pos & -pos) ft[pos] += val;
    }
    int get(int pos, int res = 0)
    {
        for (pos = pos + 1; pos > 0; pos -= pos & -pos) res += ft[pos];
        return res;
    }
};
const int N = 2e5 + 5;

vector<int>a(N);
vector<array<int,2>>t(N);

void build(int node,int l,int r)
{
    if(l == r)
    {
        if(l % 2)
        {
            t[node][1] = a[l];
            t[node][0] = 0;
        }
        else
        {
            t[node][1] = 0;
            t[node][0] = a[l];
        }
        return;
    }
    int mid = (l + r) >> 1;
    build(node * 2, l, mid);
    build(node * 2 + 1, mid + 1, r);
    t[node][1] = (t[node * 2][1] ^ t[node * 2 + 1][1]);
    t[node][2] = (t[node * 2][0] ^ t[node * 2 + 1][0]);
}
void update(int node,int l,int r,int pos,int val)
{
    if(l == r)
    {
        if(l % 2)
        {
            t[node][1] = val;
            t[node][0] = 0;
        }
        else
        {
            t[node][1] = 0;
            t[node][0] = val;
        }
        return;
    }
    int mid = (l + r) >> 1;
    if(pos <= mid)  update(node * 2, l, mid, pos, val);
    else    update(node * 2 + 1, mid + 1, r, pos, val);
    t[node][1] = (t[node * 2][1] ^ t[node * 2 + 1][1]);
    t[node][0] = (t[node * 2][0] ^ t[node * 2 + 1][0]);
}

int get_ans(int node,int l,int r, int tl,int tr, int tp)
{
    if(l <= tl && tr <= r)
    {
        return t[node][tp];
    }
    if(tr < l || tl > r)
    {
        return 0;
    }
    int mid = (tl + tr) >> 1;
    return (get_ans(node * 2, l, r, tl, mid, tp) ^ get_ans(node * 2 + 1, l, r, mid + 1, tr, tp));
}

void _()
{
    int n, q;
    cin >> n >> q;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    build(1,1,n);
    while(q--)
    {
        int t, a, b;
        cin >> t >> a >> b;
        if(t == 1)
        {
            //update(1,1,n,a,b);
        }
        else
        {
            if((b - a + 1) & 1)
            {
                cout << get_ans(1,a,b,1,n,a % 2) << endl;
            }
            else
            {
                cout << 0 << endl;
            }
        }
    }
}

signed main()
{
    OPT
    int tc = 1;
    while(tc--)
    {
        _();
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 10036 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -