답안 #634356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
634356 2022-08-24T09:26:35 Z smartmonky XORanges (eJOI19_xoranges) C++14
0 / 100
497 ms 11296 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;
const int N=3e5;
ll t[2][N*4],a[N],n;
void build(int v=1,int tl=1,int tr=n){
	if(tl==tr){
		t[(tl & 1)][v]=a[tl];
	}else{
		int mid=(tl+tr) >> 1;
		build(v*2,tl,mid);
		build(v*2+1,mid+1,tr);
	t[1][v]=(t[1][v*2]^t[1][v*2+1]);
	t[0][v]=(t[0][v*2]^t[0][v*2+1]);
	}
}
void upd(int pos,int val,int v=1, int tl=1,int tr=n){
	if(tl==tr){
		t[(tl & 1)][v]=val;
	}else{
		int mid=(tl+tr) >> 1;
		if(pos<=mid)
			upd(pos,val,v*2,tl,mid);
		else
			upd(pos,val,v*2+1,mid+1,tr);
			
	t[1][v]=(t[1][v*2]^t[1][v*2+1]);
	t[0][v]=(t[0][v*2]^t[0][v*2+1]);
	}
}
int get(int l,int r,int v=1,int tl=1,int tr=n){
	if(l>tr || r<tl)
		return 0;
	if(l<=tr && r>=tr)
		return t[(l & 1)][v];
	int mid=(tl+tr) >> 1;
	return (get(l,r,v*2,tl,mid)^get(l,r,v*2+1,mid+1,tr));
}
main(){
    int q;
    cin >> n>>q;
    for(int i=1;i<=n;i++)
		cin >>a[i];
	build();
	while(q--){
		int type,x,y;
		cin >>type >>x >>y;
		if(type==1)
			upd(x,y);
		else{
			if((y-x+1)%2==0)
				cout<<0<<endl;
			else
				cout <<(get(x,y))<<endl;
		}
	}
}

Compilation message

xoranges.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 497 ms 11296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -