# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1100950 |
2024-10-15T04:55:55 Z |
doducanh |
Secret (JOI14_secret) |
C++14 |
|
342 ms |
8268 KB |
///breaker
#include "secret.h"
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define ii pair<int,int>
#define mp make_pair
#define in(x) freopen(x,"r",stdin)
#define out(x) freopen(x,"w",stdout)
#define bit(x,i) ((x>>i)&1)
#define lc (id<<1)
#define rc ((id<<1)^1)
const int maxn=1005;
int pre[maxn][maxn];
int a[maxn];
int n;
void dac(int l,int r)
{
int m=(l+r)/2;
pre[m][m]=a[m];
pre[m+1][m+1]=a[m+1];
for(int i=m+2;i<=r;i++){
pre[m+1][i]=Secret(pre[m+1][i-1],a[i]);
}
for(int i=m-1;i>=l;i--){
pre[m][i]=Secret(a[i],pre[m][i+1]);
}
if(l<m)dac(l,m);
if(m+1<r)dac(m+1,r);
}
void Init(int N,int A[])
{
n=N;
for(int i=0;i<n;i++){
a[i]=A[i];
}
dac(0,n-1);
}
int Query(int l,int r)
{
int lo=0,hi=n-1;
while(lo!=hi){
int m=(lo+hi)/2;
if(m>=l&&m<r){
return Secret(pre[m][l],pre[m+1][r]);
}
else if(m==r){
return pre[m][l];
}
else if(m<l){
lo=m+1;
}
else hi=m;
}
return pre[lo][lo];
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
6728 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
85 ms |
6728 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
87 ms |
6720 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
312 ms |
8164 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
319 ms |
8268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
342 ms |
8264 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
312 ms |
8264 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
332 ms |
8264 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
310 ms |
8236 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
316 ms |
8264 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |