#include <bits/stdc++.h>
#include "secret.h"
#define STIZE(x) fprintf(stderr, "STIZE%lld\n", x);
#define PRINT(x) fprintf(stderr, "%s = %lld\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
#define MAXN 1010
int n, a[MAXN], d[MAXN][MAXN];
void init(int l, int r) {
if(r < l) return;
d[mid][mid] = a[mid];
for(int i = mid+1; i <= r; i++) d[mid][i] = Secret(d[mid][i-1], a[i]);
d[mid-1][mid] = a[mid-1];
for(int i = mid-2; i >= l; i--) d[i][mid] = Secret(a[i], d[i+1][mid]);
init(l, mid-1); init(mid+1, r);
}
void Init(int N, int A[]) {
n = N;
for(int i = 0; i < n; i++) a[i] = A[i];
init(0, N-1);
}
int query(int l, int r, int L, int R) {
if(L <= mid && mid <= R) {
if(L < mid) return Secret(d[L][mid],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) {
if(L == R) return a[L];
if(L+1 == R) return Secret(a[L], a[R]);
return query(0, n-1, L, R);
}
Compilation message
secret.cpp: In function 'int query(int, int, int, int)':
secret.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
177 ms |
4472 KB |
Wrong Answer: Query(493, 496) - expected : 990344084, actual : 944178838. |
2 |
Incorrect |
218 ms |
4660 KB |
Wrong Answer: Query(236, 238) - expected : 173116186, actual : 518910818. |
3 |
Incorrect |
191 ms |
4776 KB |
Wrong Answer: Query(64, 128) - expected : 469502, actual : 940800232. |
4 |
Incorrect |
655 ms |
8720 KB |
Wrong Answer: Query(545, 750) - expected : 314720826, actual : 558383304. |
5 |
Incorrect |
641 ms |
8852 KB |
Wrong Answer: Query(703, 706) - expected : 857111674, actual : 794714400. |
6 |
Incorrect |
631 ms |
8900 KB |
Wrong Answer: Query(117, 121) - expected : 983571657, actual : 590568786. |
7 |
Correct |
651 ms |
9036 KB |
Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
645 ms |
9176 KB |
Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
703 ms |
9328 KB |
Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
670 ms |
9384 KB |
Output is correct - number of calls to Secret by Init = 7499, maximum number of calls to Secret by Query = 1 |