답안 #803172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
803172 2023-08-03T00:00:25 Z Essa2006 XORanges (eJOI19_xoranges) C++14
55 / 100
159 ms 65536 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
const int pr=15, s_p=1<<pr, e_p=(1<<(pr+1))-1;
int n, q;
vector<vector<vector<int>>>S;
void pre(){
    S.resize(2, vector<vector<int>>(32, vector<int>(1<<(pr+1))));
}
void update(int par, int j, int ind, bool new_){
    S[par][j][ind]=new_;
    S[!par][j][ind]=0;
    while(ind/=2){
        S[par][j][ind]=S[par][j][ind*2]^S[par][j][ind*2+1];
        S[!par][j][ind]=S[!par][j][ind*2]^S[!par][j][ind*2+1];
    }
}
 
bool get(int id, int u, int v, int l, int r, int par, int j){
    if(l>v || r<u)
        return 0;
    if(l>=u && r<=v)
        return S[par][j][id];
    int md=(l+r)/2;
    return get(id*2, u, v, l, md, par, j)^get(id*2+1, u, v, md+1, r, par, j);
}
signed main(){
    cin>>n>>q;
    pre();
    for(int i=1, a;i<=n;i++){
        cin>>a;
        for(int j=0;j<=31;j++){
            update(i&1, j, i+s_p, ((a&(1<<j))!=0));
        }
    }
    while(q--){
        int type, i, x;
        cin>>type>>i>>x;
        if(type==1){
            for(int j=0;j<=31;j++){
                update(i&1, j, i+s_p, ((x&(1<<j))!=0));
            }
        }
        else if(type==2){
            int ans=0; 
            for(int j=0;j<=31 && (x-i+1)&1;j++){
                bool odd=get(1, i+s_p, x+s_p, s_p, e_p, i&1, j);
                if(odd)
                    ans+=1<<j;
            }
            cout<<ans<<endl;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 50388 KB Output is correct
2 Correct 26 ms 50392 KB Output is correct
3 Correct 24 ms 50388 KB Output is correct
4 Correct 29 ms 50340 KB Output is correct
5 Correct 28 ms 50444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 50516 KB Output is correct
2 Correct 29 ms 50400 KB Output is correct
3 Correct 30 ms 50400 KB Output is correct
4 Correct 26 ms 50388 KB Output is correct
5 Correct 27 ms 50388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 50388 KB Output is correct
2 Correct 26 ms 50392 KB Output is correct
3 Correct 24 ms 50388 KB Output is correct
4 Correct 29 ms 50340 KB Output is correct
5 Correct 28 ms 50444 KB Output is correct
6 Correct 28 ms 50516 KB Output is correct
7 Correct 29 ms 50400 KB Output is correct
8 Correct 30 ms 50400 KB Output is correct
9 Correct 26 ms 50388 KB Output is correct
10 Correct 27 ms 50388 KB Output is correct
11 Correct 60 ms 50356 KB Output is correct
12 Correct 61 ms 50380 KB Output is correct
13 Correct 62 ms 50476 KB Output is correct
14 Correct 62 ms 50516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 159 ms 65536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 50388 KB Output is correct
2 Correct 26 ms 50392 KB Output is correct
3 Correct 24 ms 50388 KB Output is correct
4 Correct 29 ms 50340 KB Output is correct
5 Correct 28 ms 50444 KB Output is correct
6 Correct 28 ms 50516 KB Output is correct
7 Correct 29 ms 50400 KB Output is correct
8 Correct 30 ms 50400 KB Output is correct
9 Correct 26 ms 50388 KB Output is correct
10 Correct 27 ms 50388 KB Output is correct
11 Correct 60 ms 50356 KB Output is correct
12 Correct 61 ms 50380 KB Output is correct
13 Correct 62 ms 50476 KB Output is correct
14 Correct 62 ms 50516 KB Output is correct
15 Runtime error 159 ms 65536 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -