답안 #760301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760301 2023-06-17T12:06:32 Z DJeniUp XORanges (eJOI19_xoranges) C++17
100 / 100
459 ms 10868 KB
#include "bits/stdc++.h"
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,ull>pairull;
typedef pair<ll,pairll>pair3l;
typedef long double ld;
typedef pair<ld,ll>pairld;
 
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define N 100007
//#define MOD 998244353
#define INF 1000000000000000007
#define eps 0.0000000001
 
ll n,m,d[2*N],t[2][8*N];

void BT(ll x,ll l,ll r){
    if(l==r){
        t[0][x]=d[l];
        return ;
    }
    ll m1=(l+r)/2;
    BT(x*2+1,l,m1);
    BT(x*2+2,m1+1,r);
    t[0][x]=(t[0][x*2+1]^t[0^((m1-l+1)%2)][x*2+2]);
    t[1][x]=(t[1][x*2+1]^t[1^((m1-l+1)%2)][x*2+2]);
    return ;
}

void A(ll x,ll l,ll r,ll tl,ll y){
    if(r<tl || tl<l)return ;
    if(l==r){
        t[0][x]=y;
        return ;
    }
    ll m1=(l+r)/2;
    A(x*2+1,l,m1,tl,y);
    A(x*2+2,m1+1,r,tl,y);
    t[0][x]=(t[0][x*2+1]^t[0^((m1-l+1)%2)][x*2+2]);
    t[1][x]=(t[1][x*2+1]^t[1^((m1-l+1)%2)][x*2+2]);
    return ;
}

ll R(ll x,ll l,ll r,ll tl,ll tr,ll y){
    if(r<tl || tr<l)return 0;
    if(tl<=l && r<=tr)return t[y][x];
    ll m1=(l+r)/2;
    ll h=max(0ll,min(tr,m1)-max(l,tl)+1);
    return (R(x*2+1,l,m1,tl,tr,y)^R(x*2+2,m1+1,r,tl,tr,(y^h%2)));
}

int main(){
    
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>d[i];
    }
    BT(0,1,n);
    for(int i=1;i<=m;i++){
        ll tp;
        cin>>tp;
        if(tp==1){
            ll x,y;
            cin>>x>>y;
            A(0,1,n,x,y);
        }else{
            ll x,y;
            cin>>x>>y;
            if((y-x)%2==1)cout<<0<<endl;
            else cout<<R(0,1,n,x,y,0)<<endl;
        }
    }
 
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 304 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 304 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 10 ms 596 KB Output is correct
12 Correct 8 ms 572 KB Output is correct
13 Correct 10 ms 684 KB Output is correct
14 Correct 12 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 426 ms 9160 KB Output is correct
2 Correct 429 ms 10868 KB Output is correct
3 Correct 459 ms 10776 KB Output is correct
4 Correct 414 ms 10840 KB Output is correct
5 Correct 425 ms 10808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 304 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 10 ms 596 KB Output is correct
12 Correct 8 ms 572 KB Output is correct
13 Correct 10 ms 684 KB Output is correct
14 Correct 12 ms 576 KB Output is correct
15 Correct 426 ms 9160 KB Output is correct
16 Correct 429 ms 10868 KB Output is correct
17 Correct 459 ms 10776 KB Output is correct
18 Correct 414 ms 10840 KB Output is correct
19 Correct 425 ms 10808 KB Output is correct
20 Correct 349 ms 10252 KB Output is correct
21 Correct 331 ms 10168 KB Output is correct
22 Correct 343 ms 10188 KB Output is correct
23 Correct 407 ms 10860 KB Output is correct
24 Correct 401 ms 10700 KB Output is correct