# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1086708 |
2024-09-11T09:45:10 Z |
LeonidCuk |
Secret (JOI14_secret) |
C++17 |
|
315 ms |
4524 KB |
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
vector<int>v,dp[20];
int n;
void daq(int i,int l,int r)
{
if(l==r)
{
dp[i][l]=v[l];
return;
}
int m=(l+r)/2;
dp[i][m]=v[m];
for(int j=m-1;j>=l;j--)
{
dp[i][j]=Secret(v[j],dp[i][j+1]);
}
dp[i][m+1]=v[m+1];
for(int j=m+2;j<=r;j++)
{
dp[i][j]=Secret(dp[i][j-1],v[j]);
}
daq(i+1,l,m);
daq(i+1,m+1,r);
}
int najdi(int i,int l,int r,int tl,int tr)
{
if(tl==tr)
{
return v[l];
}
int m=(tl+tr)/2;
if(l<=m&&m<r)
{
return Secret(dp[i][l],dp[i][r]);
}
else if(r<=m)
{
return najdi(i+1,l,r,tl,m);
}
else
{
return najdi(i+1,l,r,m+1,tr);
}
}
void Init(int N,int A[])
{
n=N;
for(int i=0;i<N;i++)
{
v.push_back(A[i]);
}
for(int i=0;i<20;i++)
{
dp[i].resize(N);
}
daq(0,0,N-1);
}
int Query(int l,int r)
{
return najdi(0,l,r,0,n-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
2384 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 |
2604 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
84 ms |
2632 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
310 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
315 ms |
4524 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
310 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
307 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
311 ms |
4436 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
315 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
308 ms |
4356 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |