Submission #803755

# Submission time Handle Problem Language Result Execution time Memory
803755 2023-08-03T05:49:48 Z 8pete8 Secret (JOI14_secret) C++14
100 / 100
398 ms 4348 KB
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
const int mxn=1e3;
int ans[11][mxn+10];
int v[mxn+10],mask[mxn+10];
void solve(int l,int r,int lev){
    if(l==r)return;
    int m=(r+l)/2;
    ans[lev][m]=v[m];
    for(int i=m-1;i>=l;i--)ans[lev][i]=Secret(v[i],ans[lev][i+1]);
    ans[lev][m+1]=v[m+1];
    for(int i=m+2;i<=r;i++)ans[lev][i]=Secret(ans[lev][i-1],v[i]);
    for(int i=m+1;i<=r;i++)mask[i]^=(1ll<<lev);
    solve(l,m,lev+1);
    solve(m+1,r,lev+1);
}
void Init(int N,int A[]){
    for(int i=0;i<N;i++)v[i]=A[i];
    solve(0,N-1,0);
}
int Query(int L,int R){
    if(L==R)return v[L];
    int b=__builtin_ctz(mask[L]^mask[R]);
    return Secret(ans[b][L],ans[b][R]);
}
# Verdict Execution time Memory Grader output
1 Correct 119 ms 2344 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 111 ms 2340 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 110 ms 2356 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 390 ms 4348 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 379 ms 4316 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 387 ms 4324 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 382 ms 4288 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 382 ms 4328 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 383 ms 4312 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 398 ms 4244 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1