#include <bits/stdc++.h>
#include "secret.h"
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
typedef pair <int, int> pii;
const int Inf = 2e9;
const int mod = 998244353;
const double Pi = acos(-1);
void Fastio()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int n;
int a[2005];
int Table[1005][1005];
void Create(int l, int r)
{
if(r - l <= 1)
{
return;
}
int mid = (l + r) >> 1;
for(int i = mid - 1; i >= l; i--)
{
Table[i][mid] = Secret(a[i], Table[i + 1][mid]);
}
for(int i = mid + 2; i <= r; i++)
{
Table[mid + 1][i] = Secret(Table[mid + 1][i - 1], a[i]);
}
Create(l, mid);
Create(mid + 1, r);
}
void Init(int N, int b[])
{
n = N;
for(int i = 0; i < n; i++)
{
a[i] = b[i];
for(int j = i; j < n; j++)
{
Table[i][j] = Inf;
}
Table[i][i] = a[i];
}
Create(0, n - 1);
}
int Query(int l, int r)
{
if(r == l)
{
return a[r];
}
else if(r - l == 1)
{
return Secret(a[l], a[l + 1]);
}
else
{
if(Table[l][r] != Inf)
{
return Table[l][r];
}
for(int i = l; i < r; i++)
{
if(Table[l][i] != Inf and Table[i + 1][r] != Inf)
{
return Secret(Table[l][i], Table[i + 1][r]);
}
}
}
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:85:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
4344 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
147 ms |
4472 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
155 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
507 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
510 ms |
8316 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
501 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
512 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
513 ms |
8440 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 |
8440 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
518 ms |
8524 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |