# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
708004 |
2023-03-10T17:37:27 Z |
Dan4Life |
Secret (JOI14_secret) |
C++17 |
|
451 ms |
8244 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1010;
int n, a[mxN], ans[mxN][mxN];
void dnc(int l, int r){
if(l==r) return;
int m = (l+r)/2; ans[m][m]=a[m], ans[m+1][m+1]=a[m+1];
for(int i = m-1; i>=l; i--) ans[i][m] = Secret(a[i],ans[i+1][m]);
for(int i = m+2; i<=r; i++) ans[m+1][i] = Secret(ans[m+1][i-1],a[i]);
dnc(l,m), dnc(m+1,r);
}
int dnc2(int l, int r, int L, int R){
int m = (l+r)/2;
if(L<=m and m<R)
return Secret(ans[L][m],ans[m+1][R]);
if(m<L) return dnc2(m+1,r,L,R);
return dnc2(l,m,L,R);
}
void Init(int N, int A[]) {
for(int i = 0; i < N; i++) a[i]=A[i];
dnc(0,N-1); n=N;
}
int Query(int L, int R) {
if(L==R) return a[L];
return dnc2(0,n-1,L,R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
122 ms |
4384 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
123 ms |
4372 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
124 ms |
4300 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
441 ms |
8168 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
433 ms |
8232 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
442 ms |
8244 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
445 ms |
8216 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
446 ms |
8212 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
433 ms |
8168 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
451 ms |
8232 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |