#include <bits/stdc++.h>
using namespace std;
#include "secret.h"
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[1005], n, sp[12][1005], cnt;
void Init(int N, int A[]) {
n = N;
for(int i=0;i<n;i++)a[i] = A[i];
while((1 << cnt) <= n)cnt++;
cnt--;
for(int i = 0; i < cnt; i++){
int blk = (1 << i);
int sz = (n + blk - 1) / blk;
for(int j = 1; j <= blk; j++){
int lb = (j - 1) * sz, ub = min(n - 1, j * sz - 1);
if(lb >= n)break;
int mid = (lb + ub) >> 1;
for(int k = mid; k >= lb; k--){
if(k == mid)sp[i][mid] = a[mid];
else sp[i][k] = Secret(a[k], sp[i][k + 1]);
}
for(int k = mid + 1; k <= ub; k++){
if(k == mid + 1)sp[i][k] = a[k];
else sp[i][k] = Secret(sp[i][k-1], a[k]);
}
}
}
}
int Query(int L, int R) {
if(L == R)return a[L];
int brr = L ^ R;
brr = cnt - (31 - __builtin_clz(brr)) - 1;
return Secret(sp[brr][L], sp[brr][R]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
111 ms |
2352 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 17921311. |
2 |
Correct |
124 ms |
2368 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Incorrect |
130 ms |
2388 KB |
Wrong Answer: Query(128, 153) - expected : 959658850, actual : 346459316. |
4 |
Incorrect |
455 ms |
4368 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 274825282. |
5 |
Incorrect |
438 ms |
4316 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 307380480. |
6 |
Incorrect |
443 ms |
4212 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 715804745. |
7 |
Incorrect |
451 ms |
4292 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 803195407. |
8 |
Incorrect |
437 ms |
4316 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 143491001. |
9 |
Incorrect |
449 ms |
4448 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 657796239. |
10 |
Incorrect |
449 ms |
4324 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 895754570. |