답안 #658214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658214 2022-11-12T11:55:38 Z Dzadzo XORanges (eJOI19_xoranges) C++17
38 / 100
552 ms 8156 KB
#include<bits/stdc++.h>
#define MAX 100000
using namespace std;
int t1[MAX],t2[MAX],n1,n2;
vector <int> k1,k2;
void update1 (int x ,int delta){
	for (   ;x<=n1;x+=x&-x)t1[x]^=delta;
}
int sum1 (int x){
	int sum=0;
	for (   ;x>=1;x-=x&-x)sum^=t1[x];
	return sum;
}
void update2 (int x ,int delta){
	for (   ;x<=n2;x+=x&-x)t2[x]^=delta;
}
int sum2 (int x){
	int sum=0;
	for (   ;x>=1;x-=x&-x)sum^=t2[x];
	return sum;
}
void update1_ (int x ,int delta){
	int a=x;
	for (   ;x<=n1;x+=x&-x)t1[x]^=delta^k1[a];
}
void update2_ (int x ,int delta){
	int a=x;
	for (   ;x<=n2;x+=x&-x)t2[x]^=delta^k2[a];
}
int main(){
	int n,q;
	cin>>n>>q;
	k2.push_back(-1);
	k1.push_back(-1);
	for (int i=1;i<=n;i++){
		int a;
		cin>>a;
		if (i%2==0)k2.push_back(a);else k1.push_back(a);
	}
	n1=k1.size()-1;
	n2=k2.size()-1;
	for (int i=1;i<=n1;i++)update1(i,k1[i]);
	for (int i=1;i<=n2;i++)update2(i,k2[i]);
	while (q--){
		int a,b,c;
		cin>>a>>b>>c;
		if (a==1){
			if (b%2==1){
				b=b/2+1;
				update1_(b,c);
				k1[b]=c;
			}
			if (b%2==0){
				b/=2;
				update2_(b,c);
				k2[b]=c;
				
			}
			continue;
		}
		if (a==2 && (c-b)%2==1){
			cout<<0<<"\n";continue;
		}
		if (b%2==1){
			b=b/2+1;
			c=c/2+1;
			int ans=sum1(c)^sum1(b-1);
			cout<<ans<<"\n";	
		}else
		if (b%2==0){
			b/=2;
			c/=2;
			int ans=sum2(c)^sum2(b-1);
			cout<<ans<<"\n";				
		}
	}
	
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 316 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 524 ms 8156 KB Output is correct
2 Correct 507 ms 8056 KB Output is correct
3 Correct 481 ms 8084 KB Output is correct
4 Correct 466 ms 7736 KB Output is correct
5 Correct 552 ms 7828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -