# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366273 | rocks03 | Secret (JOI14_secret) | C++14 | 568 ms | 4516 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.
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define Re(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Secret(int, int);
const int MAXK = 10;
const int MAXN = 1e3;
int N, *a, st[MAXK][MAXN];
void solve(int l, int r, int lev){
if(l == r) return;
int m = (l + r) / 2;
st[lev][m] = a[m], st[lev][m + 1] = a[m + 1];
Re(i, m - 1, l){
st[lev][i] = Secret(a[i], st[lev][i + 1]);
}
rep(i, m + 2, r + 1){
st[lev][i] = Secret(st[lev][i - 1], a[i]);
}
solve(l, m, lev + 1); solve(m + 1, r, lev + 1);
}
int query(int l, int r, int lev, int ql, int qr){
int m = (l + r) / 2;
if(ql <= m && m <= qr){
if(ql == m + 1) return st[lev][qr];
else if(qr == m) return st[lev][ql];
else return Secret(st[lev][ql], st[lev][qr]);
}
if(qr <= m) return query(l, m, lev + 1, ql, qr);
else return query(m + 1, r, lev + 1, ql, qr);
}
void Init(int n, int A[]){
N = n, a = A;
solve(0, N - 1, 0);
}
int Query(int L, int R){
if(L == R) return a[L];
else return query(0, N - 1, 0, L, R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |