Submission #634303

#TimeUsernameProblemLanguageResultExecution timeMemory
634303smartmonkyXORanges (eJOI19_xoranges)C++14
75 / 100
330 ms11092 KiB
#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=1e6;
int p[2][N];
main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    int n,q;
    cin >> n>>q;
    vector <int> v(n+1);
    for(int i=1;i<=n;i++){
		cin >>v[i];
		p[i%2][i]=v[i];
		p[0][i]^=p[0][i-1];
		p[1][i]^=p[1][i-1];
	}
	if(n<=5e3 && q<=5e3){
		while(q--){
			int type,x,y;
			cin >>type >>x >>y;
			if(type==1)
				v[x]=y;
			else{
					int res=0;
					if((y-x)%2)
						cout<<0 <<endl;
					else{
						for(int i=x;i<=y;i+=2)
							res^=v[i];
						cout <<res <<endl;
					}
			}
		}
	}else{
		while(q--){
			int type,x,y;
			cin >>type >>x >>y;
			if(type==1)
				v[x]=y;
			else{
					if((y-x)%2)
						cout<<0 <<endl;
					else{
						cout<<(p[x%2][y]^p[x%2][x-1]) <<endl;
					}
			}
		}
	}
}

Compilation message (stderr)

xoranges.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...