# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
532506 |
2022-03-03T03:36:29 Z |
Evang |
Secret (JOI14_secret) |
C++17 |
|
447 ms |
4524 KB |
#include "secret.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
static const int N = 1005;
static int n, a[N];
vector<int> lef[N], rig[N];
void evan(int l, int r){
if(l==r)
return;
int m = (l+r)/2;
lef[m].pb(a[m]);
for(int i = m-1; i >= l; --i)
lef[m].pb(Secret(a[i], lef[m].back()));
rig[m+1].pb(a[m+1]);
for(int i = m+2; i <= r; ++i)
rig[m+1].pb(Secret(rig[m+1].back(), a[i]));
evan(l, m);
evan(m+1, r);
}
void Init(int N, int A[]) {
n = N;
for(int i = 0; i < n; ++i)
a[i] = A[i];
evan(0, n-1);
}
int Query(int l, int r) {
int il = 0, ir = n-1;
while(il<ir){
int m = (il+ir)/2;
if(l<=m && m < r)
return Secret(lef[m][m-l], rig[m+1][r-m-1]);
if(m < l)
il = m+1;
else
ir = m;
}
return a[r];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
2504 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
119 ms |
2508 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
120 ms |
2504 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
447 ms |
4484 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
430 ms |
4448 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
427 ms |
4424 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
442 ms |
4492 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
441 ms |
4440 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
435 ms |
4524 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
435 ms |
4480 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |