답안 #246793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246793 2020-07-10T09:06:36 Z Sho10 XORanges (eJOI19_xoranges) C++14
100 / 100
135 ms 11128 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,q,a[200005],bit[3][200005];
void build(ll s1,ll pos,ll val){
for(;pos<=n;pos+=pos&(-pos)){
    bit[s1][pos]^=val;
}
}
void update(ll s1,ll pos,ll val){
    ll m=pos;
for(;pos<=2*n;pos+=pos&(-pos)){
    bit[s1][pos]=bit[s1][pos]^a[m]^val;
}
a[m]=val;
}
ll query(ll s1,ll pos){
ll res=0;
if(pos<=0){
    return 0;
}
for(;pos;pos-=pos&(-pos)){
    res^=bit[s1][pos];
}
return res;
}
int32_t main(){
CODE_START;
cin>>n>>q;
for(ll i=1;i<=n;i++)
{
bit[1][i]=0;
bit[0][i]=0;
}
//cout<<"DA"<<endl;
for(ll i=1;i<=n;i++)
{
    cin>>a[i];
    if(i%2==0){
        build(1,i,a[i]);
    }else {
   build(0,i,a[i]);
    }
}
//cout<<"DA"<<endl;
while(q--){
    ll t,x,y;
    cin>>t>>x>>y;
//cout<<"DA"<<endl;
    if(t==1){
        if(x%2==0){
            update(1,x,y);
        }else update(0,x,y);
    }else {
    if((x-y+1)%2==0){
    cout<<0<<endl;
    }else {
    if(y%2==1){
        cout<<(query(0,y)^query(0,x-2))<<endl;
    }else cout<<(query(1,y)^query(1,x-2))<<endl;
}
    }
}
}


# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 7 ms 640 KB Output is correct
12 Correct 7 ms 640 KB Output is correct
13 Correct 8 ms 640 KB Output is correct
14 Correct 7 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 11128 KB Output is correct
2 Correct 122 ms 11060 KB Output is correct
3 Correct 115 ms 11128 KB Output is correct
4 Correct 106 ms 10744 KB Output is correct
5 Correct 108 ms 10744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 7 ms 640 KB Output is correct
12 Correct 7 ms 640 KB Output is correct
13 Correct 8 ms 640 KB Output is correct
14 Correct 7 ms 640 KB Output is correct
15 Correct 119 ms 11128 KB Output is correct
16 Correct 122 ms 11060 KB Output is correct
17 Correct 115 ms 11128 KB Output is correct
18 Correct 106 ms 10744 KB Output is correct
19 Correct 108 ms 10744 KB Output is correct
20 Correct 121 ms 10840 KB Output is correct
21 Correct 127 ms 10876 KB Output is correct
22 Correct 120 ms 10884 KB Output is correct
23 Correct 135 ms 10744 KB Output is correct
24 Correct 111 ms 10744 KB Output is correct