Submission #961386

#TimeUsernameProblemLanguageResultExecution timeMemory
961386ByeWorldSecret (JOI14_secret)C++14
0 / 100
398 ms5204 KiB
#include "secret.h" #include <bits/stdc++.h> #include <random> #define ll long long // #define int long long #define fi first #define se second #define pb push_back #define md ((l+r)>>1) #define lf (id<<1) #define rg ((id<<1)|1) #define ld long double using namespace std; typedef pair<ll,ll> pii; typedef pair<pii,pii> ipii; const ll MAXN = 1e3+10; const ll MAXA = 1e6+10; const ll INF = 2e18+10; const ll LOG = 30; const ll MOD = 1e9+7; ll n; ll a[MAXN], dep[MAXN]; map <pii, ll> m; void bd(ll DEP, ll l, ll r){ if(l>r) return; // cout << DEP << ' ' << l << ' ' << r << " pp\n"; ll mid = md; dep[mid] = DEP; if(l==r) return; ll val = a[mid]; for(ll i=mid-1; i>=l; i--){ val = Secret(a[i], val); // ke kiri m[pii(i, mid)] = val; } val = a[mid+1]; for(ll i=mid+2; i<=r; i++){ val = Secret(val, a[i]); // ke kanan m[pii(mid+1, i)] = val; } bd(DEP+1, l, mid-1); bd(DEP+1, mid+1, r); } void Init(int N, int x[]) { n = N; for(ll i=0; i<n; i++){ a[i+1] = x[i]; m[pii(i+1, i+1)] = x[i]; } bd(1, 1, n); // for(ll i=1; i<=n; i++) cout << dep[i] << " \n"[i==n]; } int Query(int L, int R) { L++; R++; ll idx = -1, mn = INF; for(ll i=L; i<=R; i++){ if(mn > dep[i]){ idx = i; mn = dep[i]; } } return (int)Secret(m[pii(L, idx)], m[pii(idx+1, R)]); }
#Verdict Execution timeMemoryGrader output
Fetching results...