# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
220350 | Matteo_Verz | XORanges (eJOI19_xoranges) | C++11 | 149 ms | 8788 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
const int INF = 2e9;
const int N = 2e5;
int n, q;
int v[5 + N];
class AIB{
private:
int a[5 + N];
int lsb(int i){
return (i & (-i));
}
public:
void Build(int pos, int val){
for(int i = pos; i <= n; i += lsb(i))
a[i] = a[i] ^ val;
}
void Update(int pos, int val){
for(int i = pos; i <= n; i += lsb(i))
a[i] = a[i] ^ v[pos] ^ val;
v[pos] = val;
}
int Query(int pos){
int s(0);
for(int i = pos; i >= 1; i -= lsb(i))
s ^= a[i];
return s;
}
};
AIB FenwOdd, FenwEven;
int main() {
#ifdef CP
freopen("xoranges.in", "r", stdin);
freopen("xoranges.out", "w", stdout);
#endif // CP
scanf("%d%d", &n, &q);
for(int i = 1; i <= n; i++){
scanf("%d", &v[i]);
if(i & 1) FenwOdd.Build(i, v[i]);
else FenwEven.Build(i, v[i]);
}
while(q--){
int t, x, y;
scanf("%d%d%d", &t, &x, &y);
if(t == 1){
if(x & 1) FenwOdd.Update(x, y);
else FenwEven.Update(x, y);
} else{
if((x - y + 1) & 1){
if(y & 1) printf("%d\n", FenwOdd.Query(y) ^ FenwOdd.Query(x - 2));
else printf("%d\n", FenwEven.Query(y) ^ FenwEven.Query(x - 2));
} else printf("0\n");
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |