#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
int n, a[1005], pre[1005][1005];
void dnc(int l, int r){
if(l == r) return;
int mid = l + r >> 1;
dnc(l, mid); dnc(mid + 1, r);
for(int i = mid - 1; i >= l; i--) pre[i][mid] = pre[mid][i] = Secret(a[i], pre[i + 1][mid]);
for(int i = mid + 1; i <= r; i++) pre[mid][i] = pre[i][mid] = Secret(pre[mid][i - 1], a[i]);
}
void Init(int N, int A[]){
for(int i = 1; i <= N; i++) a[i] = A[i - 1], pre[i][i] = a[i];
n = N;
dnc(1, n);
}
int solve(int l, int r, int lf, int rt){
if(l == r) return a[l];
int mid = l + r >> 1;
if(lf <= mid && mid <= rt){
if(lf == mid) return pre[mid][rt];
if(rt == mid) return pre[lf][mid];
return Secret(pre[lf][mid], solve(mid + 1, r, mid + 1, rt));
}
if(rt < mid) return solve(l, mid, lf, rt);
else return solve(mid + 1, r, lf, rt);
}
int Query(int L, int R){
L++; R++;
return solve(1, n, L, R);
}
Compilation message
secret.cpp: In function 'void dnc(int, int)':
secret.cpp:9:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
9 | int mid = l + r >> 1;
| ~~^~~
secret.cpp: In function 'int solve(int, int, int, int)':
secret.cpp:23:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
23 | int mid = l + r >> 1;
| ~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
147 ms |
4300 KB |
Output is partially correct - number of calls to Secret by Init = 4088, maximum number of calls to Secret by Query = 8 |
2 |
Partially correct |
145 ms |
4328 KB |
Output is partially correct - number of calls to Secret by Init = 4097, maximum number of calls to Secret by Query = 8 |
3 |
Partially correct |
142 ms |
4436 KB |
Output is partially correct - number of calls to Secret by Init = 4107, maximum number of calls to Secret by Query = 8 |
4 |
Partially correct |
466 ms |
8244 KB |
Output isn't correct - number of calls to Secret by Init = 8967, maximum number of calls to Secret by Query = 9 |
5 |
Partially correct |
486 ms |
8124 KB |
Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 9 |
6 |
Partially correct |
433 ms |
8224 KB |
Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 3 |
7 |
Partially correct |
462 ms |
8216 KB |
Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 9 |
8 |
Partially correct |
470 ms |
8156 KB |
Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 9 |
9 |
Partially correct |
465 ms |
8284 KB |
Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 9 |
10 |
Partially correct |
482 ms |
8268 KB |
Output isn't correct - number of calls to Secret by Init = 8977, maximum number of calls to Secret by Query = 9 |