# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
368119 | Sorting | Secret (JOI14_secret) | C++17 | 517 ms | 4588 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>
const int N = 1000;
const int LOGN = 11;
int n, *a;
int d[LOGN][N], mask[N];
void dnc(int l, int r, int bit){
if(l == r) return;
int mid = (l + r) >> 1;
d[bit][mid] = a[mid];
for(int i = mid - 1; i >= l; --i)
d[bit][i] = Secret(a[i], d[bit][i + 1]);
d[bit][mid + 1] = a[mid + 1];
for(int i = mid + 2; i <= r; ++i)
d[bit][i] = Secret(d[bit][i - 1], a[i]);
for(int i = mid + 1; i <= n; ++i)
mask[i] ^= 1 << bit;
dnc(l, mid, bit + 1), dnc(mid + 1, r, bit + 1);
}
void Init(int N, int A[]){
n = N, a = A;
dnc(0, n - 1, 0);
}
int Query(int l, int r){
if(l == r) return a[r];
int bits = __builtin_ctz(mask[l] ^ mask[r]);
return Secret(d[bits][l], d[bits][r]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |