답안 #999715

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
999715 2024-06-16T05:43:53 Z vjudge1 XORanges (eJOI19_xoranges) C++14
18 / 100
34 ms 32180 KB
/*       ==========================
        | Bismillahirrahmanirrahim | ⠀⠀ 
         ==========================
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠁⠸⢳⡄⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠃⠀⠀⢸⠸⠀⡠⣄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠃⠀⠀⢠⣞⣀⡿⠀⠀⣧⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⡖⠁⠀⠀⠀⢸⠈⢈⡇⠀⢀⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⡴⠩⢠⡴⠀⠀⠀⠀⠀⠈⡶⠉⠀⠀⡸⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢀⠎⢠⣇⠏⠀⠀⠀⠀⠀⠀⠀⠁⠀⢀⠄⡇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢠⠏⠀⢸⣿⣴⠀⠀⠀⠀⠀⠀⣆⣀⢾⢟⠴⡇⠀⠀⠀⠀⠀<===== this is wolf, not everest
⠀⠀⠀⠀⠀⢀⣿⠀⠠⣄⠸⢹⣦⠀⠀⡄⠀⠀⢋⡟⠀⠀⠁⣇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⡾⠁⢠⠀⣿⠃⠘⢹⣦⢠⣼⠀⠀⠉⠀⠀⠀⠀⢸⡀⠀⠀⠀⠀
⠀⠀⢀⣴⠫⠤⣶⣿⢀⡏⠀⠀⠘⢸⡟⠋⠀⠀⠀⠀⠀⠀⠀⠀⢳⠀⠀⠀⠀
⠐⠿⢿⣿⣤⣴⣿⣣⢾⡄⠀⠀⠀⠀⠳⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢣⠀⠀⠀
⠀⠀⠀⣨⣟⡍⠉⠚⠹⣇⡄⠀⠀⠀⠀⠀⠀⠀⠀⠈⢦⠀⠀⢀⡀⣾⡇⠀⠀
⠀⠀⢠⠟⣹⣧⠃⠀⠀⢿⢻⡀⢄⠀⠀⠀⠀⠐⣦⡀⣸⣆⠀⣾⣧⣯⢻⠀⠀
⠀⠀⠘⣰⣿⣿⡄⡆⠀⠀⠀⠳⣼⢦⡘⣄⠀⠀⡟⡷⠃⠘⢶⣿⡎⠻⣆⠀⠀
⠀⠀⠀⡟⡿⢿⡿⠀⠀⠀⠀⠀⠙⠀⠻⢯⢷⣼⠁⠁⠀⠀⠀⠙⢿⡄⡈⢆⠀
⠀⠀⠀⠀⡇⣿⡅⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠦⠀⠀⠀⠀⠀⠀⡇⢹⢿⡀
⠀⠀⠀⠀⠁⠛⠓⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠼⠇⠁ 

m : 11059739 -> l ~23
p : 4567896467
*/
#pragma GCC optimize("O3", "inline")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(v) v.begin(), v.end()
#define ins insert
#define pb push_back
#define int long long int
#define pii pair<int, int>
#define str string
#define endl '\n'
#define drop(x) cout<<(x)<<endl;return;
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T> using ot = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = 998244353, sze =4*1e5 + 10, inf = 1e9, prime = 4567896467;

struct genuisahmed{
    
    vector<int> lst;
    int n;
    int T[sze];
    genuisahmed(int _n,vector<int> arr){
        lst=arr;
        n=_n;
        build(1,0,n-1);
    }

    void build(int node,int l,int r){
        if(l==r){
            T[node]=lst[l];
            return;
        }
        int mid = (l+r)/2;
        build(2*node,l,mid);
        build(2*node +1,mid+1,r);
        T[node]= T[node*2] ^ T[node *2 +1];
    }

    int qry(int node,int lx,int rx,int l,int r){
        if(l>rx || r<lx){
            return 0;
        }
        if(l>=lx && r<=rx){
            return T[node];
        }
        int mid = (l+r)/2;
        int left = qry(2*node,lx,rx,l,mid);
        int right = qry(2*node +1,lx,rx,mid+1,r);
        return left ^ right;
    }
    int qry(int l,int r){
        return qry(1,l,r,0,n-1);
    }

    void update(int node,int idx,int l,int r,int v){
        if(l==r){
            T[node]=v;
            return;
        }
        int mid = (l+r)/2;
        if(mid>=idx){
            update(2*node,idx,l,mid,v);
        }
        else{
            update(2*node,idx,mid+1,r,v);

        }
        T[node]= T[node*2] ^ T[node *2 +1];
    }

    void update(int idx,int v){
        update(1,idx,0,n-1,v);
    }

    
};

void mal(){
    /*
        obvs :
        range len cut olanda cavab 0 olur

        cut segtree

        basladigi indexe gore, cut indexlilerin xoru goturulmur
    */
    // str s="abcdefgjk";
    // int n=s.size();
    // map<char,int> count;
    // for(int i=1;i<=n;i++){
    //     for(int j=0;j+i<=n;j++){
    //         str t="";
    //         for(int x=j;x<j+i;x++){
    //             t+=s[x];
    //             count[s[x]]++;
    //         }    
    //         cout<<t<<" ";
    //     }    
    //     cout<<endl;
    // }
    // for(auto v:s){
    //     cout<<v<<" "<<count[v]<<endl;
    // }

    int n,q;
    cin>>n>>q;
    vector<int> arr(n);
    vector<int> arr1(n);
    vector<int> arr2(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        arr2[i]=arr[i];
        arr1[i]=arr[i];
        if((i+1)%2==0){
            arr1[i]=0;
        }
        else{
            arr2[i]=0;
        }
    }
    genuisahmed ahmed_tek(n,arr1);
    genuisahmed ahmed_cut(n,arr2);
    // cout<<ahmed_tek.qry(0,2)<<endl;
    vector<pii> tekqueries,cutqueries;
    while(q--){
        int op;
        cin>>op;

        if(op==2){
            int l,r;
            cin>>l>>r;

            if( (r-l+1)%2==0){
                cout<<0<<endl;
            }
            else{
                l--;
                r--;
                if((l+1)%2){
                    // tekden baslayir, cut indexliler sayilmiyacaq
                    cout<<ahmed_tek.qry(l,r)<<endl;
                }
                else{
                    // cutden basliyir, TEKLERI SIL
                    cout<<ahmed_cut.qry(l,r)<<endl;
                }
            }
        }
        else{
            int idx,v;
            cin>>idx>>v;
        }
    }
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int tt = 1;
    // cin>>tt;

    while (tt--) mal();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6488 KB Output is correct
2 Correct 4 ms 6748 KB Output is correct
3 Correct 3 ms 6720 KB Output is correct
4 Correct 3 ms 6724 KB Output is correct
5 Correct 4 ms 6748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 32180 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -