Submission #657821

# Submission time Handle Problem Language Result Execution time Memory
657821 2022-11-11T11:31:52 Z cpp219 XORanges (eJOI19_xoranges) C++17
100 / 100
191 ms 11248 KB
#include<bits/stdc++.h>
#define ll int
#define ld double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 2e5 + 9;
const ll mod = 1e9 + 7;

ll n,q,a[N];
ll st[4*N][2];

void upd(ll id,ll type,ll l,ll r,ll u,ll val){
    if (u < l||r < u) return;
    if (l == r){
        st[id][type] ^= val; return;
    }
    ll mid = (l + r)/2;
    upd(id*2,type,l,mid,u,val);
    upd(id*2 + 1,type,mid + 1,r,u,val);
    st[id][type] = st[id*2][type] ^ st[id*2 + 1][type];
}

ll Get(ll id,ll type,ll l,ll r,ll u,ll v){
    if (v < l||r < u) return 0;
    if (u <= l&&r <= v) return st[id][type];
    ll mid = (l + r)/2;
    return Get(id*2,type,l,mid,u,v) ^ Get(id*2 + 1,type,mid + 1,r,u,v);
}

int main(){
    ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
    #define task "test"
    if (fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    cin>>n>>q;
    for (ll i = 1;i <= n;i++){
        cin>>a[i];
        upd(1,i%2,1,n,i,a[i]);
    }
    while(q--){
        ll type; cin>>type;
        if (type == 1){
            ll pos,val; cin>>pos>>val;
            upd(1,pos%2,1,n,pos,a[pos]);
            a[pos] = val;
            upd(1,pos%2,1,n,pos,a[pos]);
        }
        else{
            ll l,r; cin>>l>>r;
            if ((r - l + 1)%2){
                cout<<Get(1,l%2,1,n,l,r)<<"\n";
            }
            else cout<<0<<"\n";
        }
    }
}
/* be confident */

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 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 4 ms 596 KB Output is correct
12 Correct 4 ms 600 KB Output is correct
13 Correct 4 ms 596 KB Output is correct
14 Correct 4 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 11248 KB Output is correct
2 Correct 149 ms 11212 KB Output is correct
3 Correct 142 ms 11244 KB Output is correct
4 Correct 146 ms 10960 KB Output is correct
5 Correct 137 ms 10988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 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 4 ms 596 KB Output is correct
12 Correct 4 ms 600 KB Output is correct
13 Correct 4 ms 596 KB Output is correct
14 Correct 4 ms 608 KB Output is correct
15 Correct 165 ms 11248 KB Output is correct
16 Correct 149 ms 11212 KB Output is correct
17 Correct 142 ms 11244 KB Output is correct
18 Correct 146 ms 10960 KB Output is correct
19 Correct 137 ms 10988 KB Output is correct
20 Correct 191 ms 10908 KB Output is correct
21 Correct 178 ms 11000 KB Output is correct
22 Correct 191 ms 10920 KB Output is correct
23 Correct 140 ms 10856 KB Output is correct
24 Correct 158 ms 10844 KB Output is correct