#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, r);
for(int i = mid - 1; i >= l; i--) pre[i][mid] = Secret(a[i], pre[i + 1][mid]);
for(int i = mid + 1; i <= r; i++) pre[mid][i] = 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){
int mid = l + r >> 1;
if(lf <= mid && mid <= rt){
if(lf == mid) return pre[mid][rt];
else if(rt == mid) return pre[lf][mid];
return Secret(pre[lf][mid - 1], pre[mid][rt]);
}
if(rt < mid) return solve(l, mid, lf, rt);
else return solve(mid, 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:22:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
22 | int mid = l + r >> 1;
| ~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
337 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Runtime error |
325 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Runtime error |
339 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Runtime error |
667 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Runtime error |
634 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Runtime error |
645 ms |
524288 KB |
Execution killed with signal 9 |
7 |
Runtime error |
673 ms |
524288 KB |
Execution killed with signal 9 |
8 |
Runtime error |
672 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Runtime error |
656 ms |
524288 KB |
Execution killed with signal 9 |
10 |
Runtime error |
662 ms |
524288 KB |
Execution killed with signal 9 |