답안 #925523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925523 2024-02-11T22:42:12 Z Sputnik123 XORanges (eJOI19_xoranges) C++14
100 / 100
108 ms 12552 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <cstdio>
#define pb push_back
#define in insert
#define pll pair<ll,ll>
#define vpl vector<pll>
#define vll vector <ll>
#define vl vector<ll>
///#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define endl "\n"
#define ll long long 
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
//  #pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt,fma")
const ll sz=2e5+5;
const ll inf=1e12+7;
const ll mod=1e9+7;
const ll P=47;
///const double e=1e-6;
ll gcd(ll x,ll y)
{
    return (y ? gcd(y,x%y) : x);
}
ll lcm(ll x,ll y)
{
    return (x/gcd(x,y))*y;
}
ll binpow(ll a,ll b)
{
    ll ans=1;
    a%=mod;
    while(b)
    {
        ans=(b&1 ? (ans*a)%mod : ans);
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}
ll modm(ll n,ll m,ll md=mod)
{
    if(!m)  return 1;
    ll res=modm(n,m>>1,md);
    if(m&1) return res*res%md*n%md;
    return res*res%md;
}
bool isprime(ll n){
    if(n<3)    return false;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)  return  false;
    }
    return true;
}
ll n,q,cur;
ll a[sz],t[sz<<2],d[sz],na[sz];
void build(ll node,ll l,ll r)
{
    if(l==r)
    {
        t[node]=na[l];
        return ;
    }
    ll mid=(l+r)>>1;
    build(node<<1,l,mid);
    build(node<<1|1,mid+1,r);
    t[node]=((t[node<<1])^(t[node<<1|1]));
}
void update(ll node,ll l,ll r,ll pos,ll val)
{
    if(l==r and l==pos)
    {
        t[node]=val;
        na[l]=val;
        return ;
    }
    ll mid=(l+r)>>1;
    if(pos<=mid)
        update(node<<1,l,mid,pos,val);
    else
        update(node<<1|1,mid+1,r,pos,val);
    t[node]=((t[node<<1])^(t[node<<1|1]));
}
ll get(ll node,ll l,ll r,ll ql,ll qr)
{
    if(l>qr || r<ql)    return 0;
    if(ql<=l and r<=qr) return t[node];
    ll mid=(l+r)>>1;
    return (get(node<<1,l,mid,ql,qr))^(get(node<<1|1,mid+1,r,ql,qr));
}
void solve()
{
    cin>>n>>q;
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    for(ll i=1;i<=n;i+=2)
    {
        d[i]=++cur;
        na[cur]=a[i];
    }
    for(ll i=2;i<=n;i+=2)
    {
        d[i]=++cur;
        na[cur]=a[i];
    }
    build(1,1,n);
    while(q--)
    {
        ll ta,l,r;
        cin>>ta>>l>>r;
        if(ta==1)
        {
            update(1,1,n,d[l],r);
        }
        else
        {
            if((r-l+1)%2==0){    cout<<0<<endl;continue; }
            else                cout<<get(1,1,n,d[l],d[r])<<endl;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 3 ms 6488 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 3 ms 6492 KB Output is correct
14 Correct 3 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 12540 KB Output is correct
2 Correct 96 ms 12552 KB Output is correct
3 Correct 92 ms 12368 KB Output is correct
4 Correct 85 ms 12372 KB Output is correct
5 Correct 84 ms 12420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6488 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 3 ms 6488 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 3 ms 6492 KB Output is correct
14 Correct 3 ms 6492 KB Output is correct
15 Correct 95 ms 12540 KB Output is correct
16 Correct 96 ms 12552 KB Output is correct
17 Correct 92 ms 12368 KB Output is correct
18 Correct 85 ms 12372 KB Output is correct
19 Correct 84 ms 12420 KB Output is correct
20 Correct 97 ms 11856 KB Output is correct
21 Correct 91 ms 11856 KB Output is correct
22 Correct 91 ms 11864 KB Output is correct
23 Correct 84 ms 12472 KB Output is correct
24 Correct 108 ms 12440 KB Output is correct