# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
464423 | kilikuma | XORanges (eJOI19_xoranges) | C++14 | 165 ms | 9524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long arbreImpair[(1<<19)+42] = {0};
long arbrePair[(1<<19)+42] = {0};
long xorImpair = 0, xorPair = 0;
void modifieImpair(int a) {
while (a>0) {
arbreImpair[a] = arbreImpair[a*2]^arbreImpair[a*2+1];
// printf("%ld\n", arbreImpair[a]);
a = a/2;
}
}
void modifiePair(int a) {
while (a>0) {
arbrePair[a] = arbrePair[a*2]^arbrePair[a*2+1];
// printf("%ld\n", arbrePair[a]);
a = a/2;
}
}
void interImpair(int a, int b) {
if (a>b) return;
if (a==b) {
xorImpair = xorImpair^arbreImpair[a];
return;
}
if ((a%2) == 1){
xorImpair = xorImpair^arbreImpair[a];
a++;
}
if ((b%2) == 0) {
xorImpair = xorImpair^arbreImpair[b];
b--;
}
interImpair(a/2, b/2);
}
void interPair(int a, int b) {
if (a>b) {
// printf("what did happen");
return;
}
// printf("%d %d\n", a, b);
//printf("Please tell me where this went wrong");
if (a==b) {
xorPair = xorPair^arbrePair[a];
// printf("%ld\n", arbrePair[a]);
return;
}
if ((a%2) == 1) {
xorPair = xorPair^arbrePair[a];
// printf("%ld\n", arbrePair[a]);
a ++;
}
if ((b%2) == 0) {
xorPair = xorPair^arbrePair[b];
//printf("%ld\n", arbrePair[b]);
// ;
b--;
}
// printf("OMG");
interPair(a/2, b/2);
}
int main() {
int DEC = (1<<18);
int nbElements, nbRequetes;
scanf("%d%d",&nbElements,&nbRequetes);
long b;
int l, r;
int pos; long val;
for (int i = 0; i< nbElements;i++) {
scanf("%ld",&b);
if ((i+1)%2) {
arbreImpair[i+DEC] = b;
modifieImpair((i+DEC)/2);
// printf("%d\n", (i+DEC));
}
else {
arbrePair[i+DEC] = b;
modifiePair((i+DEC)/2);
// printf("%d\n", (i+DEC));
}
}
for (int q = 0; q < nbRequetes; q ++) {
int idQ; scanf("%d",&idQ);
if (idQ == 1) {
scanf("%d%ld", &pos, &val);
if (pos%2) {
arbreImpair[pos+DEC-1] = val;
modifieImpair((pos+DEC-1)/2);
}
else {
arbrePair[pos+DEC-1] = val;
modifiePair((pos+DEC-1)/2);
}
}
else {
scanf("%d%d",&l,&r);
xorImpair = 0; xorPair = 0;
if ((r-l)%2) {
printf("%d\n", 0);
}
else {
if (r%2) {
interImpair(l+DEC-1,r+DEC-1);
// printf("%ld %ld\n", l+DEC-1, r+DEC-1);
printf("%ld \n", xorImpair);
}
else {
interPair(l+DEC-1,r+DEC-1);
printf("%ld\n", xorPair);
}
}
}
}
}
컴파일 시 표준 에러 (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... |