#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++;
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 |
Correct |
122 ms |
2340 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Incorrect |
114 ms |
2388 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 124326376. |
3 |
Incorrect |
114 ms |
2352 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 471212. |
4 |
Incorrect |
433 ms |
4300 KB |
Wrong Answer: Query(877, 959) - expected : 912310978, actual : 598262492. |
5 |
Incorrect |
444 ms |
4304 KB |
Wrong Answer: Query(761, 790) - expected : 112945480, actual : 955460636. |
6 |
Incorrect |
423 ms |
4328 KB |
Wrong Answer: Query(250, 258) - expected : 907404, actual : 12475405. |
7 |
Correct |
433 ms |
4292 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
448 ms |
4372 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
455 ms |
4248 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
439 ms |
4392 KB |
Output is correct - number of calls to Secret by Init = 7998, maximum number of calls to Secret by Query = 1 |