#include "secret.h"
#include <bits/stdc++.h>
//Dost SEFEROĞLU
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<
#define vi vector<int>
#define all(xx) xx.begin(),xx.end()
#define ps(xxx) cout << (xxx) << endl;
int dat[10][1001];
int mask[1001];
int B[1001];
void dnc(int l,int r,int level = 0) {
if (l == r) {
dat[level][l] = B[l];
return;
}
int m = (l+r) >> 1;
for (int i=m+1;i<=r;i++) mask[i]^=(1<<level);
dat[level][m] = B[m];
for (int i=m-1;i>=l;i--) dat[level][i] = Secret(B[i],dat[level][i+1]);
dat[level][m+1] = B[m+1];
for (int i=m+2;i<=r;i++) dat[level][i] = Secret(dat[level][i-1],B[i]);
dnc(l,m,level+1),dnc(m+1,r,level+1);
}
void Init(int32_t N, int32_t A[]) {
for (int i=0;i<N;i++) B[i] = A[i];
dnc(1,N);
}
int32_t Query(int32_t L, int32_t R) {
if (L == R) return B[L];
int tz = __builtin_ctz(mask[L]^mask[R]);
return Secret(dat[tz][L],dat[tz][R]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
80 ms |
2904 KB |
Wrong Answer: Query(0, 357) - expected : 574893848, actual : 823469616. |
2 |
Incorrect |
79 ms |
2896 KB |
Wrong Answer: Query(0, 218) - expected : 167946665, actual : 979444105. |
3 |
Incorrect |
79 ms |
2896 KB |
Wrong Answer: Query(0, 359) - expected : 218322958, actual : 94884132. |
4 |
Incorrect |
298 ms |
4432 KB |
Wrong Answer: Query(0, 229) - expected : 58228789, actual : 359301677. |
5 |
Incorrect |
306 ms |
4376 KB |
Wrong Answer: Query(0, 371) - expected : 250238024, actual : 720031834. |
6 |
Incorrect |
309 ms |
4380 KB |
Wrong Answer: Query(0, 7) - expected : 421989048, actual : 145425737. |
7 |
Incorrect |
306 ms |
4432 KB |
Wrong Answer: Query(0, 993) - expected : 589312106, actual : 692290594. |
8 |
Incorrect |
320 ms |
4436 KB |
Wrong Answer: Query(0, 839) - expected : 428261768, actual : 881024464. |
9 |
Incorrect |
305 ms |
4548 KB |
Wrong Answer: Query(0, 930) - expected : 424418475, actual : 29375662. |
10 |
Incorrect |
309 ms |
4468 KB |
Wrong Answer: Query(0, 893) - expected : 611994251, actual : 539903305. |