#include <bits/stdc++.h>
#include "secret.h"
#define mid (l+r)/2
using namespace std;
#define MAXN 1010
int n, a[MAXN], d[MAXN][MAXN];
void init(int l, int r) {
if(l >= r) return;
for(int i = 0; i < n; i++) d[i][i] = a[i];
for(int i = mid+1; i <= r; i++) d[mid][i] = Secret(d[mid][i-1], a[i]);
for(int i = mid-2; i >= l; i--) d[i][mid-1] = Secret(a[i], d[i+1][mid-1]);
init(l, mid-1); init(mid+1, r);
}
void Init(int N, int A[]) {
n = N;
for(int i = 1; i <= n; i++) a[i] = A[i-1];
init(1, N);
}
int query(int l, int r, int L, int R) {
if(L <= mid && mid <= R) {
if(L < mid) return Secret(d[L][mid-1],d[mid][R]);
else return d[mid][R];
}
if(mid < L) return query(mid+1, r, L, R);
if(R < mid) return query(l, mid-1, L, R);
}
int Query(int L, int R) {
L++; R++;
if(L == R) return a[L];
if(L+1 == R) return Secret(a[L], a[R]);
return query(1, n, L+1, R+1);
}
Compilation message
secret.cpp: In function 'int query(int, int, int, int)':
secret.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
182 ms |
4344 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 307655478. |
2 |
Incorrect |
192 ms |
4580 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 539081064. |
3 |
Incorrect |
178 ms |
4672 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 355475528. |
4 |
Incorrect |
611 ms |
8476 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 569475659. |
5 |
Incorrect |
650 ms |
8544 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 987791438. |
6 |
Incorrect |
674 ms |
8544 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 318712044. |
7 |
Incorrect |
623 ms |
8608 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 785056803. |
8 |
Incorrect |
639 ms |
8608 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 560296976. |
9 |
Incorrect |
644 ms |
8608 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 299376775. |
10 |
Incorrect |
642 ms |
8620 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 4663113. |