# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
321989 |
2020-11-13T16:35:24 Z |
bigg |
Secret (JOI14_secret) |
C++14 |
|
507 ms |
4460 KB |
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
int tot, maxa;
int qual[MAXN][15];
int a[MAXN];
int n;
void recur(int l, int r, int altura){
if(l >= r || l == r-1) return;
int mid = (l + r)/2;
qual[mid][altura] = a[mid];
qual[mid+1][altura] = a[mid+1];
for(int i = mid - 1; i >= l; i--)qual[i][altura] = Secret(a[i], qual[i+1][altura]);
for(int i = mid + 2; i <= r; i++)qual[i][altura] = Secret(qual[i-1][altura], a[i]);
recur(l, mid - 1, altura + 1);
recur(mid + 1, r, altura + 1);
}
int makeans(int x, int y, int L, int R, int altura){
int mid = (x+y)/2;
if(R < mid) return makeans(x, mid - 1, L, R, altura + 1);
if(L > mid) return(makeans(mid + 1, y, L, R, altura + 1));
if(R == mid) return qual[L][altura];
return Secret(qual[L][altura], qual[R][altura]);
}
void Init(int N, int A[]) {
n = N;
for(int i = 1; i <= N; i++) a[i] = A[i-1];
recur(1, n, 0);
//printf("%d %d\n", tot, maxa);
}
int Query(int L, int R) {
L++;
R++;
if(L==R) return a[L];
if( L == R-1) return Secret(a[L], a[R]);
return makeans(1,n,L,R,0);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
140 ms |
2560 KB |
Output is correct - number of calls to Secret by Init = 3331, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
142 ms |
2432 KB |
Output is correct - number of calls to Secret by Init = 3339, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
142 ms |
2576 KB |
Output is correct - number of calls to Secret by Init = 3347, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
504 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7467, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
503 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
504 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
507 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
504 ms |
4332 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
502 ms |
4332 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
506 ms |
4460 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |