Submission #959776

#TimeUsernameProblemLanguageResultExecution timeMemory
959776irmuunSecret (JOI14_secret)C++17
0 / 100
364 ms11828 KiB
#include<bits/stdc++.h> #include "secret.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() const ll maxn=1e3+5; int n; vector<pair<int,int>>v; int pre[maxn][maxn],suf[maxn][maxn]; int a[maxn]; void build(int l,int r){ if(l+1>=r) return; int mid=(l+r)/2; suf[mid][mid]=a[mid]; for(int i=mid-1;i>=l;i--){ suf[mid][i]=Secret(suf[mid][i+1],a[i]); } pre[mid+1][mid+1]=a[mid+1]; for(int i=mid+2;i<=r;i++){ pre[mid+1][i]=Secret(pre[mid+1][i-1],a[i]); } build(l,mid); build(mid+1,r); } int ask(int l,int r,int L,int R){ int mid=(l+r)/2; if(R<=mid){ return ask(l,mid,L,R); } if(L>=mid+1){ return ask(mid+1,r,L,R); } return Secret(suf[mid][L],pre[mid+1][R]); } void Init(int N,int A[]){ n=N; for(int i=0;i<n;i++){ a[i]=A[i]; } build(0,n-1); } int Query(int l,int r){ if(l==r){ return a[l]; } if(l+1==r){ return Secret(a[l],a[r]); } return ask(0,n-1,l,r); }
#Verdict Execution timeMemoryGrader output
Fetching results...