Submission #634362

# Submission time Handle Problem Language Result Execution time Memory
634362 2022-08-24T09:41:21 Z smartmonky XORanges (eJOI19_xoranges) C++14
0 / 100
503 ms 11276 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()
#define int ll
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){
	//	cout << (tl&1) <<" " <<v  <<" "<< a[tl]<<endl;
		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(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 503 ms 11276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -