Submission #18747330


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s^=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]^=v,e+=e&-e;}
};
BIT<int,20> bt;

int N,Q;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,N) {
		cin>>x;
		bt.add(i+1,x);
	}
	while(Q--) {
		cin>>i>>x>>y;
		if(i==1) {
			bt.add(x,y);
		}
		else {
			cout<<(bt(y)^bt(x-1))<<endl;
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task F - Range Xor Query
User kmjp
Language C++ (GCC 9.2.1)
Score 600
Code Size 1313 Byte
Status AC
Exec Time 500 ms
Memory 4784 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:27:8: warning: unused variable ‘j’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |        ^
./Main.cpp:27:10: warning: unused variable ‘k’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:27:12: warning: unused variable ‘l’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:27:14: warning: unused variable ‘r’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:49:38: note: in expansion of macro ‘FOR’
   49 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All handmade_00.txt, handmade_01.txt, max_00.txt, max_01.txt, max_02.txt, max_03.txt, max_04.txt, max_05.txt, max_06.txt, max_07.txt, power_of_2_00.txt, power_of_2_01.txt, power_of_2_02.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
handmade_00.txt AC 7 ms 3620 KB
handmade_01.txt AC 3 ms 3652 KB
max_00.txt AC 307 ms 4784 KB
max_01.txt AC 312 ms 4620 KB
max_02.txt AC 312 ms 4620 KB
max_03.txt AC 479 ms 4728 KB
max_04.txt AC 497 ms 4784 KB
max_05.txt AC 500 ms 4716 KB
max_06.txt AC 118 ms 4664 KB
max_07.txt AC 309 ms 4728 KB
power_of_2_00.txt AC 267 ms 4580 KB
power_of_2_01.txt AC 268 ms 4596 KB
power_of_2_02.txt AC 269 ms 4480 KB
random_00.txt AC 269 ms 3800 KB
random_01.txt AC 191 ms 4372 KB
random_02.txt AC 73 ms 3536 KB
random_03.txt AC 250 ms 4348 KB
random_04.txt AC 42 ms 3604 KB
sample_01.txt AC 3 ms 3584 KB
sample_02.txt AC 5 ms 3588 KB