Submission #297522

#TimeUsernameProblemLanguageResultExecution timeMemory
297522penguinhackerSecret (JOI14_secret)C++17
0 / 100
527 ms4600 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; #define ll long long #define ar array /*int Secret(int a, int b) { return min(a, b); }*/ template<class T> struct range_query { int n; vector<T> a; vector<vector<T>> st; void init(vector<T> _a) { a = _a; n = a.size(); int x = 0; while((1 << x) < n) { ++x; } a.resize(1 << x); st.assign(1 << x, vector<T>(x)); build(0, (1 << x) - 1, x - 1); } T combine(T a, T b) { return Secret(a, b); } void build(int l, int r, int lev) { if (lev < 0) { return; } int mid = (l + r) >> 1; st[mid][lev] = a[mid]; for (int i = mid - 1; i >= l; --i) { st[i][lev] = combine(st[i + 1][lev], a[i]); } if (r > mid) { st[mid + 1][lev] = a[mid + 1]; for (int i = mid + 2; i <= r; ++i) { st[i][lev] = combine(st[i -1][lev], a[i]); } } build(l, mid, lev - 1); build(mid + 1, r, lev - 1); } T qry(int l, int r) { assert(l <= r); if (l == r) { return a[l]; } int x = 31 - __builtin_clz(l ^ r); return combine(st[l][x], st[r][x]); } }; range_query<int> rq; void Init(int N, int A[]) { vector<int> a(A, A + N); rq.init(a); } int Query(int L, int R) { return rq.qry(L, R); } /*int main() { ios::sync_with_stdio(0); cin.tie(0); return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...