Submission #873156

#TimeUsernameProblemLanguageResultExecution timeMemory
873156ace_in_the_holeSecret (JOI14_secret)C++17
0 / 100
368 ms4744 KiB
#include "secret.h" #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> using namespace std; #define all(v) (v).begin(), (v).end() #define cst(T) const T& template<class A, class B> bool umin(A& var, cst(B) val) { return (val < var) ? (var = val, true) : false; } template<class A, class B> bool umax(A& var, cst(B) val) { return (var < val) ? (var = val, true) : false; } typedef long long Int; typedef long double Real; const int MOD = 2004010501; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<class X, class Y> Int random(const X& l, const Y& r) { return uniform_int_distribution<Int>(l,r)(rng); } #define DBG(x) cerr << #x << " = " << x << ' '; #define DBGn(x) cerr << #x << " = " << x << '\n'; const int N = 1005; const int LG = 11; vector<int> a; int n; int mask[N], dat[LG][N]; void dnc(int l, int r, int lev) { if (l == r) return ; int m = (l+r) / 2; dat[lev][m] = a[m]; for (int i = m-1; i >= l; i--) dat[lev][i] = Secret(a[i], dat[lev][i+1]); dat[lev][m+1] = a[m+1]; for (int i = m+1; i <= r; i++) dat[lev][i] = Secret(dat[lev][i-1], a[i]); for (int i = m+1; i <= r; i++) mask[i] ^= 1<<lev; dnc(l,m, lev+1); dnc(m+1,r, lev+1); } void Init(int _n, int arr[]) { n = _n; a.insert(end(a), arr, arr+n); dnc(0, n-1, 0); } int Query(int L, int R) { if (L == R) return a[L]; int lev = __builtin_ctz(mask[L] ^ mask[R]); return Secret(dat[lev][L], dat[lev][R]); }
#Verdict Execution timeMemoryGrader output
Fetching results...