# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1018610 | dosts | Secret (JOI14_secret) | C++17 | 318 ms | 4688 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 "secret.h"
#include <bits/stdc++.h>
//Dost SEFEROĞLU
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<
#define vi vector<int>
#define all(xx) xx.begin(),xx.end()
#define ps(xxx) cout << (xxx) << endl;
int dat[10][1001];
int mask[1001];
int B[1001];
void dnc(int l,int r,int level = 0) {
if (l == r) return;
int m = (l+r) >> 1;
dat[level][m] = B[m];
for (int i=m-1;i>=l;i--) dat[level][i] = Secret(B[i],dat[level][i+1]);
dat[level][m+1] = B[m+1];
for (int i=m+2;i<=r;i++) dat[level][i] = Secret(dat[level][i-1],B[i]);
for (int i=m+1;i<=r;i++) mask[i]^=(1<<level);
dnc(l,m,level+1),dnc(m+1,r,level+1);
}
void Init(int32_t N, int32_t A[]) {
for (int i=0;i<N;i++) B[i+1] = A[i];
dnc(1,N);
}
int32_t Query(int32_t L, int32_t R) {
L++;
R++;
if (L == R) return B[L];
int tz = __builtin_ctz(mask[L]^mask[R]);
return Secret(dat[tz][L],dat[tz][R]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |