Submission #989765

# Submission time Handle Problem Language Result Execution time Memory
989765 2024-05-28T18:33:01 Z Zbyszek99 XORanges (eJOI19_xoranges) C++17
100 / 100
93 ms 8276 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace std;
//mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll rand(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;

int wiel = 1024*512-1;
int drzewo[2][1024*512-1];

int query_t(int akt, int p1, int p2, int s1, int s2, int p)
{
    if(p2 < s1 || p1 > s2) return 0;
    if(p1 >= s1 && p2 <= s2) return drzewo[p][akt-1];
    return query_t(akt*2,p1,(p1+p2)/2,s1,s2,p) ^ query_t(akt*2+1,(p1+p2)/2+1,p2,s1,s2,p);
}

void add_t(int akt, int p)
{
    drzewo[p][akt-1] = drzewo[p][akt*2-1] ^ drzewo[p][akt*2];
    if(akt != 1) add_t(akt/2,p);
}

void change_t(int poz, int war, int p)
{
    drzewo[p][wiel/2+poz] = war;
    add_t((wiel/2+poz+1)/2,p);
}

void solve()
{
    int n,q;
    cin >> n >> q;
    rep(i,n)
    {
        int a;
        cin >> a;
        change_t(i/2,a,i%2);
    }
    rep(i,q)
    {
        int type,a,b;
        cin >> type >> a >> b;
        if(type == 1)
        {
            change_t((a-1)/2,b,(a-1)%2);
        }
        else
        {
            if((b-a+1) % 2 == 0) cout << 0 << "\n";
            else 
            {
                cout << query_t(1,0,wiel/2,(a-1)/2,(b-1)/2,(a-1)%2) << "\n";
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //random();
    int t = 1;
    //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 600 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 4 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 8276 KB Output is correct
2 Correct 87 ms 8020 KB Output is correct
3 Correct 93 ms 8016 KB Output is correct
4 Correct 84 ms 7744 KB Output is correct
5 Correct 80 ms 7764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 600 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 4 ms 672 KB Output is correct
15 Correct 88 ms 8276 KB Output is correct
16 Correct 87 ms 8020 KB Output is correct
17 Correct 93 ms 8016 KB Output is correct
18 Correct 84 ms 7744 KB Output is correct
19 Correct 80 ms 7764 KB Output is correct
20 Correct 80 ms 7684 KB Output is correct
21 Correct 88 ms 7836 KB Output is correct
22 Correct 77 ms 7684 KB Output is correct
23 Correct 79 ms 7572 KB Output is correct
24 Correct 83 ms 7760 KB Output is correct