#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int O = 2e3 + 5;
//const int N = (1 << 20) + 5;
const int mod = 1e9 + 7; //998244353;
const int inf = 1e18;
int pr[] = {167772161, 469762049, 754974721, 1045430273, 1051721729, 1053818881};
const double eps = 1e-10;
int a[O], mask[O], f[21][O];
void DnC(int l, int r, int level){
if (level > 8 || l > r) return;
int mid = (l + r) / 2;
DnC(l, mid, level + 1);
DnC(mid + 1, r, level + 1);
f[level][mid] = a[mid];
for (int i = mid - 1; i >= l; ++ i) f[level][i] = Secret(f[level][i + 1], a[i]);
f[level][mid + 1] = a[mid + 1];
for (int i = mid + 2; i <= r; ++ i) f[level][i] = Secret(f[level][i - 1], a[i]);
for (int i = mid + 1; i <= r; ++ i) mask[i] |= (1 << level);
}
void Init(int N, int A[]){
for (int i = 0; i < N; ++ i) a[i] = A[i];
DnC(0, N - 1, 0);
}
int Query(int L, int R){
if (L == R) return a[L];
int x, cur = mask[L] ^ mask[R];
for (int i = 0; i < 10; ++ i){
if (cur >> i & 1){
x = i;
break;
}
}
return Secret(f[x][L], f[x][R]);
}
/*main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}*/
/**
**/
Compilation message
secret.cpp:9:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
9 | const int inf = 1e18;
| ^~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:46:18: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
46 | return Secret(f[x][L], f[x][R]);
| ~~~~~~^~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
77 ms |
2388 KB |
Wrong Answer [1] |
2 |
Incorrect |
78 ms |
2548 KB |
Wrong Answer [1] |
3 |
Incorrect |
82 ms |
2384 KB |
Wrong Answer [1] |
4 |
Incorrect |
294 ms |
4276 KB |
Wrong Answer [1] |
5 |
Incorrect |
300 ms |
4432 KB |
Wrong Answer [1] |
6 |
Incorrect |
293 ms |
4292 KB |
Wrong Answer [1] |
7 |
Incorrect |
302 ms |
4432 KB |
Wrong Answer [1] |
8 |
Incorrect |
303 ms |
4292 KB |
Wrong Answer [1] |
9 |
Incorrect |
302 ms |
4432 KB |
Wrong Answer [1] |
10 |
Incorrect |
284 ms |
4432 KB |
Wrong Answer [1] |