Submission #84074

# Submission time Handle Problem Language Result Execution time Memory
84074 2018-11-12T19:01:36 Z Bodo171 Secret (JOI14_secret) C++14
100 / 100
736 ms 5612 KB
#include "secret.h"
#include <iostream>
const int nmax=1005;
using namespace std;
int arb[12][nmax];
int v[nmax];
int i,Ll,Rr,ans;
void divide(int st,int dr,int lev)
{
    if(st==dr)
    {
        arb[lev][st]=v[st];
        return;
    }
    int m=(st+dr)/2;
    arb[lev][m]=v[m];
    if(m+1<=dr)
        arb[lev][m+1]=v[m+1];
    for(i=m-1;i>=st;i--)
        arb[lev][i]=Secret(v[i],arb[lev][i+1]);
    for(i=m+2;i<=dr;i++)
        arb[lev][i]=Secret(arb[lev][i-1],v[i]);
    divide(st,m,lev+1);
    divide(m+1,dr,lev+1);
}
int n;
void Init(int N, int A[]) {
  n=N;
  for(i=0;i<N;i++)
    v[i+1]=A[i];
  divide(1,N,0);
}
void query(int st,int dr,int lev)
{
    int m=(st+dr)/2;
    if(Ll<=m&&m<Rr)
    {
        ans=Secret(arb[lev][Ll],arb[lev][Rr]);
        return;
    }
    if(Ll<=m) query(st,m,lev+1);
    else query(m+1,dr,lev+1);
}
int Query(int L, int R) {
  L++,R++;
  if(L==R)
    return v[L];
  Ll=L;Rr=R;
  query(1,n,0);
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 177 ms 2552 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 188 ms 2716 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 2764 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 620 ms 4936 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 638 ms 5008 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 649 ms 5272 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 613 ms 5296 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 736 ms 5388 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 634 ms 5500 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 626 ms 5612 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1