Submission #1171398

#TimeUsernameProblemLanguageResultExecution timeMemory
1171398ezzzaySecret (JOI14_secret)C++20
0 / 100
608 ms589824 KiB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
vector<int>a;
vector<int>st;
void build(int node, int L, int R){
    if(L==R){
        st[node]=a[L];
        return ;
    }
    int mid= ( L + R);
    build(node*2,L,mid);
    build(node*2+1,mid+1,R);
    st[node]= Secret(st[node*2],st[node*2+1]);
}
int find(int node, int L, int R, int l, int r){
    if(L>r or l>R)return -1;
    if(l<=L and R<=r)return st[node];
    int mid= ( L+R);
    int x= find(node*2,L,mid,l,r);
    int y=find(node*2+1, mid+1,R,l,r);
    if(x==-1 and y==-1)return -1;
    if(x==-1)return y;
    if(y==-1)return x;
    return Secret(st[node*2],st[node*2+1]);
}
void Init(int N, int A[]) {
    a.clear();
    a.pb(0);
    st.clear();
    for(int i=0;i<N;i++)a.pb(A[i]);
    for(int i=0; i<4*N+12;i++)st.pb(0);
    build(1,1,N);
}

int Query(int L, int R) {
    L++;
    R++;
    int n=a.size() - 1;
    return find(1,1,n,L,R);
}
#Verdict Execution timeMemoryGrader output
Fetching results...