Submission #240338

# Submission time Handle Problem Language Result Execution time Memory
240338 2020-06-19T13:06:23 Z blacktulip XORanges (eJOI19_xoranges) C++17
100 / 100
204 ms 11256 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
int n,m,b[li],a[li],k,flag,t,tree[li*4],tree1[4*li],x,y,z;
int cev;
string s;
vector<int> v;
 
inline void build(int node,int start,int end){
	if(start>end)return ;
	if(start==end && start%2==1)return ;
	if(start==end && start%2==0){tree[node]=a[start];return ;}
	build(node*2,start,mid);
	build(node*2+1,mid+1,end);
	tree[node]=tree[node*2]^tree[node*2+1];
}

inline void update(int node,int start,int end,int l,int r,int val){
	if(start>end || start>r || end<l)return ;
	if(start>=l && end<=r){tree[node]=val;return ;}
	update(node*2,start,mid,l,r,val),update(node*2+1,mid+1,end,l,r,val);
	tree[node]=tree[node*2]^tree[node*2+1];
}

inline int query(int node,int start,int end,int l,int r){
	if(start>end || start>r || end<l)return 0;
	if(start>=l && end<=r){return tree[node];}
	return query(node*2,start,mid,l,r)^query(node*2+1,mid+1,end,l,r);
}

inline void build1(int node,int start,int end){
	if(start>end)return ;
	if(start==end && start%2==0)return ;
	if(start==end && start%2==1){tree1[node]=a[start];return ;}
	build1(node*2,start,mid);
	build1(node*2+1,mid+1,end);
	tree1[node]=tree1[node*2]^tree1[node*2+1];
}

inline void update1(int node,int start,int end,int l,int r,int val){
	if(start>end || start>r || end<l)return ;
	if(start>=l && end<=r){tree1[node]=val;return ;}
	update1(node*2,start,mid,l,r,val),update1(node*2+1,mid+1,end,l,r,val);
	tree1[node]=tree1[node*2]^tree1[node*2+1];
}

inline int query1(int node,int start,int end,int l,int r){
	if(start>end || start>r || end<l)return 0;
	if(start>=l && end<=r){return tree1[node];}
	return query1(node*2,start,mid,l,r)^query1(node*2+1,mid+1,end,l,r);
}

int main(void){
	scanf("%d %d",&n,&t);
	FOR{
		scanf("%d",&a[i]);
	}
	build(1,1,n);
	build1(1,1,n);
	while(t--){
		scanf("%d %d %d",&x,&y,&z);
		if(x==1){
			if(y%2==1)update1(1,1,n,y,y,z);
			else update(1,1,n,y,y,z);
			continue;
		}
		int at=z-y+1;
		if(at%2==0){printf("0\n");continue;}
		if(y%2==0){
			printf("%d\n",query(1,1,n,y,z));
		}
		else{
			printf("%d\n",query1(1,1,n,y,z));
		}
	}
	return 0;
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:75:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&t);
  ~~~~~^~~~~~~~~~~~~~~
xoranges.cpp:77:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
xoranges.cpp:82:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&x,&y,&z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 8 ms 640 KB Output is correct
12 Correct 10 ms 640 KB Output is correct
13 Correct 9 ms 640 KB Output is correct
14 Correct 10 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 203 ms 11256 KB Output is correct
2 Correct 193 ms 11256 KB Output is correct
3 Correct 184 ms 11256 KB Output is correct
4 Correct 159 ms 11000 KB Output is correct
5 Correct 162 ms 11004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 8 ms 640 KB Output is correct
12 Correct 10 ms 640 KB Output is correct
13 Correct 9 ms 640 KB Output is correct
14 Correct 10 ms 640 KB Output is correct
15 Correct 203 ms 11256 KB Output is correct
16 Correct 193 ms 11256 KB Output is correct
17 Correct 184 ms 11256 KB Output is correct
18 Correct 159 ms 11000 KB Output is correct
19 Correct 162 ms 11004 KB Output is correct
20 Correct 188 ms 10984 KB Output is correct
21 Correct 204 ms 11000 KB Output is correct
22 Correct 202 ms 11128 KB Output is correct
23 Correct 171 ms 11000 KB Output is correct
24 Correct 162 ms 11100 KB Output is correct