# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
922555 |
2024-02-05T16:36:33 Z |
hqminhuwu |
Secret (JOI14_secret) |
C++14 |
|
375 ms |
14176 KB |
#include "secret.h"
#define forr(_a,_b,_c) for(int _a = (_b); _a <= (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < (_c); ++_a)
#define st first
#define nd second
#define ll long long
using namespace std;
const int N = 2e3 + 5;
const ll oo = 1e9;
const ll mod = 1e9 + 7;
int n, f[N][N];
void calc (int l, int r, int a[]){
int mid = (l + r) / 2;
f[mid][mid] = a[mid];
f[mid + 1][mid + 1] = a[mid + 1];
for (int i = mid + 2; i <= r; i++)
f[mid + 1][i] = Secret(f[mid + 1][i - 1], a[i]);
for (int i = mid - 1; i >= l; i--)
f[mid][i] = Secret(a[i], f[mid][i + 1]);
if (l < mid) calc (l, mid, a);
if (mid + 1 < r) calc (mid + 1, r, a);
}
void Init (int u, int a[]){
n = u;
calc (0, n - 1, a);
}
int Query (int u, int v){
int l = 0, r = n - 1;
while (l != r){
int mid = (l + r) / 2;
if (mid >= u && mid < v) return Secret(f[mid][u], f[mid + 1][v]);
if (mid == v) return f[mid][u];
if (mid < u) l = mid + 1;
else r = mid;
}
return f[l][l];
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
9632 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
106 ms |
9752 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
106 ms |
10068 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
358 ms |
13924 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
363 ms |
13924 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
356 ms |
13740 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
360 ms |
13916 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
367 ms |
13904 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
358 ms |
14176 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
375 ms |
13908 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |