Submission #971933

# Submission time Handle Problem Language Result Execution time Memory
971933 2024-04-29T14:07:09 Z vjudge1 XORanges (eJOI19_xoranges) C++17
0 / 100
90 ms 9492 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
int a[N], n, q;
ll bit[2][N];
void upd(int x, int i, ll val){
	for(++i; i<N; i+=i&-i) bit[x][i] ^= val;
}
ll qry(int x, int i){
	ll res = 0; for(++i; i; i-=i&-i) res ^= bit[x][i]; return res;
}
ll sum(int x, int l, int r){
	return qry(x, r) - qry(x, l-1);
}
signed main(){
	scanf("%d %d", &n, &q);
	for(int i = 0; i<n; ++i) scanf("%d", a+i);
	for(int i = 0; i<n; ++i){
		upd(i&1, i>>1, a[i]);
	}
	while(q--){
		int t; scanf("%d", &t);
		if(t == 1){
			int i, val; scanf("%d %d", &i, &val); --i;
			upd(i&1, i>>1, val ^ a[i]);
			a[i] = val;
		}else if(t == 2){
			int l, r; scanf("%d %d", &l, &r); --l; --r;
			ll T = 0;
			if((r-l+1)&1){
				if(!(l&1)){
					T = sum(0, l>>1, r>>1);
				}else if(l&1){
					int R = r;
					if(!(R&1)) --R;
					T = sum(1, l>>1, R>>1);
				}
			}	
			printf("%lld\n", T);
		}
	}
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d %d", &n, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~
xoranges.cpp:18:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  for(int i = 0; i<n; ++i) scanf("%d", a+i);
      |                           ~~~~~^~~~~~~~~~~
xoranges.cpp:23:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   int t; scanf("%d", &t);
      |          ~~~~~^~~~~~~~~~
xoranges.cpp:25:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |    int i, val; scanf("%d %d", &i, &val); --i;
      |                ~~~~~^~~~~~~~~~~~~~~~~~~
xoranges.cpp:29:19: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |    int l, r; scanf("%d %d", &l, &r); --l; --r;
      |              ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 9492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -