Submission #1017112

# Submission time Handle Problem Language Result Execution time Memory
1017112 2024-07-08T21:14:38 Z vjudge1 XORanges (eJOI19_xoranges) C++17
0 / 100
298 ms 25172 KB
#include <bits/stdc++.h>
/// author: LilPluton auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
using namespace std;
#define int long long
const int N = 3e5 + 5;
const int INF = 1e18;
const int md = 1e9 + 7;

void show(vector<int> &a)
{
    for(auto i : a)
        cout << i << ' ';
    cout << endl;
}
int n, q;
struct tree
{
    int st[N * 4];
    tree()
    {
        memset(st, 0, sizeof(st));
    }
    void upd(int in,int l,int r,int pos,int val)
    {
        if(l == r)
        {
            st[in] = val;
            return;
        }
        int mid = (l + r) >> 1;
        if(pos <= mid)  upd(in * 2, l, mid, pos, val);
        else   upd(in * 2 + 1, mid + 1, r, pos, val);
        st[in] = st[in * 2] ^ st[in * 2 + 1];
    }
    int getans(int in,int tl,int tr,int l,int r)
    {
        if(l > r)    return 0;
        if(tl == l && tr == r)  return st[in];
        int mid = (tl + tr) / 2;
        int q1 = getans(in * 2, tl, mid, l, min(mid, r));
        int q2 = getans(in * 2, mid + 1, tr, max(mid + 1, l), r);
        return q1 ^ q2;
    }

} seg1, seg2;

signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    cin >> n >> q;
    for(int i = 1, x; i <= n; ++i)
    {
        cin >> x;
        if(i & 1)   seg1.upd(1,1,n,i / 2 + 1, x);
        else    seg2.upd(1,1,n,i/2,x);
    }
    while(q--)
    {
        int t,l,r;
        cin >> t >> l >> r;
        if(t == 1)
        {
            if(l & 1)   seg1.upd(1,1,n,l / 2 + 1, r);
            else    seg2.upd(1,1,n,l / 2, r);
        }
        else
        {
            int id = (r - l + 1);
            if(id & 1)
            {
                if(l & 1)   cout << seg1.getans(1,1,n,l / 2 + 1, l / 2 + 1 + id / 2) << endl;
                else    cout << seg2.getans(1,1,n,l / 2, l / 2 + id / 2) << endl;
            }
            else
            {
                cout << 0 << endl;
            }
        }
    }

}

# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 19032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 19032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 19032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 298 ms 25172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 19032 KB Output isn't correct
2 Halted 0 ms 0 KB -