#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
const int MAXN = 1010;
int N, ans[MAXN][MAXN];
void divide_and_conquer(int l, int r)
{
if(r - l <= 1) return;
int mid = (l + r) >> 1;
for(int i = mid - 1; l <= i; i--) ans[i][mid] = Secret(ans[i][i], ans[i + 1][mid]);
for(int i = mid + 2; i <= r; i++) ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], ans[i][i]);
divide_and_conquer(l, mid);
divide_and_conquer(mid + 1, r);
}
void Init(int n, int a[])
{
N = n;
for(int i = 0; i < N; i++) ans[i][i] = a[i];
divide_and_conquer(0, N - 1);
}
int findAns(int l, int r, int L, int R)
{
int mid = (l + r) >> 1;
if(L <= mid && mid + 1 <= R) return Secret(ans[L][mid], ans[mid + 1][R]);
if(R <= mid) return findAns(l, mid, L, R);
else return findAns(mid + 1, r, L, R);
}
int Query(int l, int r)
{
if(r - l <= 1) return Secret(ans[l][l], ans[r][r]);
return findAns(0, N - 1, l, r);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
137 ms |
4460 KB |
Wrong Answer: Query(56, 56) - expected : 677274107, actual : 421071224. |
2 |
Incorrect |
133 ms |
4460 KB |
Wrong Answer: Query(389, 389) - expected : 472506730, actual : 183032171. |
3 |
Incorrect |
133 ms |
4460 KB |
Wrong Answer: Query(18, 18) - expected : 238214183, actual : 44330347. |
4 |
Incorrect |
498 ms |
8320 KB |
Wrong Answer: Query(788, 788) - expected : 937598145, actual : 876305518. |
5 |
Incorrect |
506 ms |
8300 KB |
Wrong Answer: Query(957, 957) - expected : 115761809, actual : 370472857. |
6 |
Incorrect |
493 ms |
8284 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 31281100. |
7 |
Correct |
508 ms |
8300 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
506 ms |
8300 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
509 ms |
8324 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
516 ms |
8428 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |