# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
803744 | 8pete8 | Secret (JOI14_secret) | C++14 | 404 ms | 4324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define pb push_back
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int mxn=1e3;
int ans[11][mxn+10];
int v[mxn+10],in[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(v[i],ans[lev][i-1]);
for(int i=m+1;i<=r;i++)in[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(in[L]^in[R]);
return Secret(ans[b][L],ans[b][R]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |