# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
569922 | jmyszka2007 | XORanges (eJOI19_xoranges) | C++17 | 162 ms | 7952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
constexpr int base = (1 << 18);
int d1[2 * base];
int d2[2 * base];
void upd1(int v, int x) {
v += base;
d1[v] = x;
v >>= 1;
while(v > 0) {
d1[v] = d1[2 * v] ^ d1[2 * v + 1];
v >>= 1;
}
}
int que1(int l, int r) {
l += base;
r += base;
int ans = 0;
while(l <= r) {
if(l & 1) {
ans ^= d1[l];
}
if(!(r & 1)) {
ans ^= d1[r];
}
l++;
l >>= 1;
r--;
r >>= 1;
}
return ans;
}
void upd2(int v, int x) {
v += base;
d2[v] = x;
v >>= 1;
while(v > 0) {
d2[v] = d2[2 * v] ^ d2[2 * v + 1];
v >>= 1;
}
}
int que2(int l, int r) {
l += base;
r += base;
int ans = 0;
while(l <= r) {
if(l & 1) {
ans ^= d2[l];
}
if(!(r & 1)) {
ans ^= d2[r];
}
l++;
l >>= 1;
r--;
r >>= 1;
}
return ans;
}
int main() {
int n, t;
scanf("%d%d", &n, &t);
for(int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
if(i & 1) {
upd1(i / 2 + 1, x);
}
else {
upd2(i / 2, x);
}
}
while(t--) {
int tp;
scanf("%d", &tp);
if(tp == 1) {
int v, x;
scanf("%d%d", &v, &x);
if(v & 1) {
upd1(v / 2 + 1, x);
}
else {
upd2(v / 2, x);
}
}
else {
int l, r;
scanf("%d%d", &l, &r);
if((l & 1) != (r & 1)) {
printf("%d\n", 0);
}
else {
if(l & 1) {
printf("%d\n", que1(l / 2 + 1, r / 2 + 1));
}
else {
printf("%d\n", que2(l / 2, r / 2));
}
}
}
}
}
컴파일 시 표준 에러 (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... |