답안 #877840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
877840 2023-11-23T17:36:04 Z slumio XORanges (eJOI19_xoranges) C++17
100 / 100
472 ms 9776 KB
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;

void add(vector<int>&tree,int &n,int k,int &num)
{

k+=n;
tree[k]=num;
for(k/=2;k>=1;k/=2)
{
   tree[k]=tree[2*k]^tree[2*k+1];
}
return;
}


int sump(vector<int>&tree,int &n,int a,int b)
{

 
 
a+=n;
b+=n;
int num=0;
while(a<=b)
{
   if(a%2==1)num^=tree[a++];
   if(b%2==0)num^=tree[b--];
    a/=2;b/=2;
}

return num;

}



 void solve(){
       
 int n;cin>>n; int q;cin>>q;
vector<int>tree1;
vector<int>tree2;

tree1.assign(2*n+5,0);
tree2.assign(2*n+5,0);

for(int i=0;i<n;i++)
{
    int m;cin>>m;
    if(i%2==0)
    {
        add(tree1,n,i,m);
    }
    else{
        add(tree2,n,i,m);
    }
}

for(int i=0;i<q;i++)
{
  int type; 
 cin>>type;
  if(type==1)
  {
     int pos,val;
     cin>>pos>>val;
     pos--;
 
     if(pos%2==0)
    {   
        add(tree1,n,pos,val);
        
       
    }
    else{
        add(tree2,n,pos,val);
         
    }

       


  }
  else{
        
     int  l,r;cin>>l>>r;
      l--;r--;
      if((r-l+1)%2==0)cout<<0<<endl;
      else{
          
    if(l%2==0)
    {
        cout<<sump(tree1,n,l,r)<<endl;
    }
    else{
        cout<<sump(tree2,n,l,r)<<endl;
    }

      }


  }


}


return;
}
int main()
{

solve();
return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 604 KB Output is correct
12 Correct 8 ms 604 KB Output is correct
13 Correct 10 ms 624 KB Output is correct
14 Correct 10 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 423 ms 9560 KB Output is correct
2 Correct 472 ms 9776 KB Output is correct
3 Correct 421 ms 9576 KB Output is correct
4 Correct 404 ms 9244 KB Output is correct
5 Correct 435 ms 9376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 432 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 8 ms 604 KB Output is correct
12 Correct 8 ms 604 KB Output is correct
13 Correct 10 ms 624 KB Output is correct
14 Correct 10 ms 604 KB Output is correct
15 Correct 423 ms 9560 KB Output is correct
16 Correct 472 ms 9776 KB Output is correct
17 Correct 421 ms 9576 KB Output is correct
18 Correct 404 ms 9244 KB Output is correct
19 Correct 435 ms 9376 KB Output is correct
20 Correct 315 ms 9296 KB Output is correct
21 Correct 327 ms 9464 KB Output is correct
22 Correct 300 ms 9300 KB Output is correct
23 Correct 403 ms 9216 KB Output is correct
24 Correct 427 ms 9196 KB Output is correct