답안 #274726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
274726 2020-08-19T14:45:43 Z keta_tsimakuridze XORanges (eJOI19_xoranges) C++14
100 / 100
240 ms 11256 KB
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,q,k,a[N],ind,x,l,r,tree[2][4*N];
void update(int u,int ind,int l,int r,int val,int p) {
	
	if(l>ind || r<ind) return;
	if(ind<=l && r<=ind) {
		tree[p][u]^=val;
		return;
	}
	int mid=(l+r)/2;
	update(2*u,ind,l,mid,val,p);
	update(2*u+1,ind,mid+1,r,val,p);
	tree[p][u]=tree[p][2*u]^tree[p][2*u+1];
}
int getans(int u,int start,int end,int l,int r,int p) {
	
	if(l>end || r<start) return 0;
	if(start<=l && r<=end) {
		return tree[p][u];
	}
	int mid=(l+r)/2;
	return getans(2*u,start,end,l,mid,p)^
	       getans(2*u+1,start,end,mid+1,r,p);
	//tree[u]=tree[2*u]^tree[2*u+1];
}

int main() {
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>q;
	for(k=1; k<=n; k++) {
		cin>>a[k];
		if(k%2==1) update(1,k,1,n,a[k],1);
		else update(1,k,1,n,a[k],0);
	
	}
	for(k=1; k<=q; k++) {
		cin>>x;
		if(x==1) {
			cin>>ind>>x; 
			if(ind%2==0) update(1,ind,1,n,a[ind]^x,0);
			else update(1,ind,1,n,a[ind]^x,1);
			a[ind]=x;	//cout<<getans(1,1,n,1,n,1)<<"+"<<endl;
		} else {
			cin>>l>>r;
			if((r-l+1)%2==0) cout<<0<<" ";
			else {

				cout<<getans(1,l,r,1,n,r%2)<<" ";
			}
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 220 ms 6396 KB Output is correct
2 Correct 223 ms 11256 KB Output is correct
3 Correct 228 ms 11256 KB Output is correct
4 Correct 197 ms 11004 KB Output is correct
5 Correct 200 ms 11000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 220 ms 6396 KB Output is correct
16 Correct 223 ms 11256 KB Output is correct
17 Correct 228 ms 11256 KB Output is correct
18 Correct 197 ms 11004 KB Output is correct
19 Correct 200 ms 11000 KB Output is correct
20 Correct 240 ms 10992 KB Output is correct
21 Correct 223 ms 11000 KB Output is correct
22 Correct 233 ms 11128 KB Output is correct
23 Correct 201 ms 10912 KB Output is correct
24 Correct 198 ms 10888 KB Output is correct