답안 #819519

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
819519 2023-08-10T11:26:36 Z Andrijanikolic73 XORanges (eJOI19_xoranges) C++17
30 / 100
1000 ms 7636 KB
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
using namespace std;
const int N=2e5+50;
const int inf=1e18;
const int mod=1e9+7;
int a[N];
int n;
int q;
struct segtree{
    int t[4*N]={0};
    void build(int v,int tl,int tr){
        if(tl==tr)t[v]=a[tl];
        else {
            int tm=(tl+tr)/2;
            build(v*2,tl,tm);
            build(v*2+1,tm+1,tr);
            t[v]=(t[v*2]^t[v*2+1]);
        }
    }
    int query(int v,int tl,int tr,int l,int r){
        if(tr<l||tl>r)return 0;
        if(l<=tl&&tr<=r)return t[v];
        int tm=(tl+tr)/2;
        return (query(v*2,tl,tm,l,r)^query(v*2+1,tm+1,tr,l,r));
    }
    void update(int v,int tl,int tr,int index,int value){
        if(tl==tr){
            t[v]=value;
        }
        else {
            int tm=(tl+tr)/2;
            if(index<=tm){
                update(v*2,tl,tm,index,value);
            }
            else {
                update(v*2+1,tm+1,tr,index,value);
            }
            t[v]=(t[v*2]^t[v*2+1]);
        }
    }
};
segtree seg;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>a[i];
    seg.build(1,1,n);
    int pref[n+1];
    for(int i=0;i<=n;i++)pref[i]=0;
    while(q--){
        int o;
        cin>>o;
        if(o==1){
            int i,x;
            cin>>i>>x;
            a[i]=x;
        }
        else {
            int l,r;
            cin>>l>>r;
            for(int i=l;i<=r;i++){
                for(int j=i;j<=r;j++){
                    pref[i]++;
                    pref[j+1]--;
                }
            }
            for(int i=l;i<=r;i++)pref[i]+=pref[i-1];
            int ans=0;
            for(int i=l;i<=r;i++){
                if(pref[i]%2)ans^=a[i];
            }
            cout<<ans;
            cout<<endl;
            for(int i=l;i<=r+1;i++)pref[i]=0;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 340 KB Output is correct
2 Correct 11 ms 340 KB Output is correct
3 Correct 15 ms 340 KB Output is correct
4 Correct 56 ms 340 KB Output is correct
5 Correct 32 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 11 ms 340 KB Output is correct
7 Correct 11 ms 340 KB Output is correct
8 Correct 15 ms 340 KB Output is correct
9 Correct 56 ms 340 KB Output is correct
10 Correct 32 ms 340 KB Output is correct
11 Execution timed out 1072 ms 596 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1060 ms 7636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 11 ms 340 KB Output is correct
7 Correct 11 ms 340 KB Output is correct
8 Correct 15 ms 340 KB Output is correct
9 Correct 56 ms 340 KB Output is correct
10 Correct 32 ms 340 KB Output is correct
11 Execution timed out 1072 ms 596 KB Time limit exceeded
12 Halted 0 ms 0 KB -