# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
464791 | 2021-08-14T07:13:11 Z | kilikuma | XORanges (eJOI19_xoranges) | C++14 | 170 ms | 7876 KB |
#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]; a = a/2; } } void modifiePair(int a) { while (a>0) { arbrePair[a] = arbrePair[a*2]^arbrePair[a*2+1]; 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) return; if (a==b) { xorPair = xorPair^arbrePair[a]; return; } if ((a%2) == 1) { xorPair = xorPair^arbrePair[a]; a ++; } if ((b%2) == 0) { xorPair = xorPair^arbrePair[b]; b--; } 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); } else { arbrePair[i+DEC] = b; modifiePair((i+DEC)/2); } } 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 \n", xorImpair); } else { interPair(l+DEC-1,r+DEC-1); printf("%ld\n", xorPair); } } } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 4 ms | 460 KB | Output is correct |
12 | Correct | 4 ms | 552 KB | Output is correct |
13 | Correct | 4 ms | 460 KB | Output is correct |
14 | Correct | 4 ms | 460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 162 ms | 7820 KB | Output is correct |
2 | Correct | 156 ms | 7800 KB | Output is correct |
3 | Correct | 156 ms | 7876 KB | Output is correct |
4 | Correct | 140 ms | 7876 KB | Output is correct |
5 | Correct | 144 ms | 7788 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 4 ms | 460 KB | Output is correct |
12 | Correct | 4 ms | 552 KB | Output is correct |
13 | Correct | 4 ms | 460 KB | Output is correct |
14 | Correct | 4 ms | 460 KB | Output is correct |
15 | Correct | 162 ms | 7820 KB | Output is correct |
16 | Correct | 156 ms | 7800 KB | Output is correct |
17 | Correct | 156 ms | 7876 KB | Output is correct |
18 | Correct | 140 ms | 7876 KB | Output is correct |
19 | Correct | 144 ms | 7788 KB | Output is correct |
20 | Correct | 151 ms | 7224 KB | Output is correct |
21 | Correct | 170 ms | 7108 KB | Output is correct |
22 | Correct | 152 ms | 7128 KB | Output is correct |
23 | Correct | 146 ms | 7752 KB | Output is correct |
24 | Correct | 146 ms | 7772 KB | Output is correct |