# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1099562 | dzhoz0 | Secret (JOI14_secret) | C++17 | 330 ms | 8888 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.
/*
ghmt the cutie :3
UwU
*/
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
#define INF 1e9
#define f first
#define s second
#define pii pair<int, int>
#define vi vector<int>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
template<typename T, int SZ> struct RangeQuery {
int n;
T stor[SZ][32-__builtin_clz(SZ)], id = 1;
vector<T> a;
T comb (T a, T b) { return Secret(a, b); } // associative operation
void fill(int l, int r, int ind) {
if (ind < 0) return;
int m = (l+r)/2;
T prod = id; ROF(i,l,m) stor[i][ind] = prod = comb(a[i],prod);
prod = id; FOR(i,m,r) stor[i][ind] = prod = comb(prod,a[i]);
fill(l,m,ind-1); fill(m,r,ind-1);
}
void init() {
n = 1; while ((1<<n) < a.size()) ++n;
a.resize(1<<n); fill(0,(1<<n),n-1);
}
T query(int l, int r) {
if (l == r) return a[l];
int t = 31-__builtin_clz(r^l);
return comb(stor[l][t],stor[r][t]);
}
};
const int MAXN = 1000;
RangeQuery<long long, MAXN + 5> rq;
void Init(int n, int a[]) {
for(int i = 0; i < n; i++) rq.a.push_back(a[i]);
rq.init();
}
int Query(int l, int r) {
return rq.query(l, r);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |