# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52585 |
2018-06-26T07:45:29 Z |
노영훈(#1364) |
Secret (JOI14_secret) |
C++11 |
|
648 ms |
8464 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int MX=1001, B=21;
int n, A[MX];
int D[MX][MX];
void _fill(int s=0, int e=n-1){
int m=(s+e)/2;
if(s==e){
D[m][m]=A[m];
return;
}
D[m][m]=A[m];
for(int x=m-1; x>=s; x--){
D[x][m]=Secret(A[x], D[x+1][m]);
}
D[m+1][m+1]=A[m+1];
for(int y=m+2; y<=e; y++)
D[m+1][y]=Secret(D[m+1][y-1], A[y]);
_fill(s,m);
_fill(m+1,e);
}
void Init(int N, int _A[]) {
n=N;
for(int i=0; i<n; i++) A[i]=_A[i];
_fill();
/*
cout<<"\nD: \n";
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
cout<<D[i][j]<<' ';
}
cout<<'\n';
}
*/
}
int solve(int l, int r, int s=0, int e=n-1){
int m=(s+e)/2;
if(l<=m && m+1<=r){
// printf("%d~%d: [%d, %d]\n", l, r, s, e);
// printf("%d * %d\n", D[l][m], D[m+1][r]);
return Secret(D[l][m], D[m+1][r]);
}
if(r<=m) return solve(l,r,s,m);
else return solve(l,r,m+1,e);
}
int Query(int L, int R) {
if(L==R) return A[L];
return solve(L,R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
174 ms |
4428 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
186 ms |
4456 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
176 ms |
4536 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
606 ms |
8460 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
608 ms |
8460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
618 ms |
8460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
606 ms |
8460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
648 ms |
8460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
608 ms |
8460 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
635 ms |
8464 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |