답안 #237602

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237602 2020-06-07T16:37:48 Z Pbezz XORanges (eJOI19_xoranges) C++14
0 / 100
248 ms 12152 KB
#include <bits/stdc++.h>
using namespace std;

#define loop(i,n) for (ll i = 0; i < n; i++)

#define ll long long
#define INF 1e9+5
#define MAXN 200007
#define pb push_back 
#define mp make_pair
typedef pair<ll,ll> pii;

ll arr[MAXN];
ll seg[4*MAXN][2];

void recalculate(ll int node){

seg[node][0]=seg[2*node+1][0]^seg[2*node+2][0];

seg[node][1]=seg[2*node+1][1]^seg[2*node+2][1];

}

void build(ll node, ll left, ll right){

	if(left==right){

	if(left%2==0){seg[node][0]=arr[left]; seg[node][1]=0; }
	else{ seg[node][1]=arr[left]; seg[node][0]=0;}

	}else{
	ll middle=(left+right)/2;

	build(2*node+1,left,middle);

	build(2*node+2,middle+1,right);

	recalculate(node);
	}

}

void update(ll node, ll left, ll right, ll x, ll y){

	if(left==right){

	if(left%2==0){seg[node][0]=y; seg[node][1]=0; }
	else{ seg[node][1]=y; seg[node][0]=0;}

	}else{

	ll middle=(left+right)/2;

	if(x<=middle){
		update(2*node+1,left,middle,x,y);
	}else{
		update(2*node+2,middle+1,right,x,y);
	}

	recalculate(node);

	}

}
ll bruh;
ll querie(ll node, ll left, ll right, ll a, ll b){

	if(a<=left&&b>=right)return seg[node][bruh];

	ll middle=(left+right)/2,ans=0;

	if(a<=middle)ans^=querie(2*node+1,left,middle,a,b);

	if(b>=middle+1)ans^=querie(2*node+2,middle+1,right,a,b);

	return ans;

}


int main(){

	ll n,q,type,i,j,l,r;
	cin>>n>>q;


	loop(i,n){

	scanf("%lld",&arr[i+1]);

}
	build(0,1,n);

	while(q--){

	scanf("%lld",&type);

	if(type==1){

	scanf("%lld%lld",&i,&j);

	arr[i]=j;
	update(0,1,n,i,j);

	}else{

	scanf("%lld%lld",&l,&r);
	bruh=l%2;

	printf("%lld\n",querie(0,1,n,l,r));



	}
}

return 0;
}
 

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:89:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&arr[i+1]);
  ~~~~~^~~~~~~~~~~~~~~~~~
xoranges.cpp:96:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&type);
  ~~~~~^~~~~~~~~~~~~~
xoranges.cpp:100:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&i,&j);
  ~~~~~^~~~~~~~~~~~~~~~~~
xoranges.cpp:107:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&l,&r);
  ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 248 ms 12152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -