Submission #540774

#TimeUsernameProblemLanguageResultExecution timeMemory
540774Yazan_AlattarSecret (JOI14_secret)C++14
100 / 100
448 ms18496 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 300007; const ll inf = 2e9; const ll mod = 1e9+7; const double pi = acos(-1); const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0}; const int block = 320; #include "secret.h" int n, a[M]; vector <int> suf[M], pref[M]; void build(int node = 1, int l = 1, int r = n){ if(l == r){ suf[node].pb(a[l]); return; } int mid = (l + r) / 2; build(2 * node, l, mid); build(2 * node + 1, mid + 1, r); int x = a[mid]; suf[node].pb(x); for(int i = mid - 1; i >= l; --i){ x = Secret(a[i], x); suf[node].pb(x); } x = a[mid + 1]; pref[node].pb(x); for(int i = mid + 2; i <= r; ++i){ x = Secret(x, a[i]); pref[node].pb(x); } return; } void Init(int N, int A[]){ n = N; for(int i = 1; i <= n; ++i) a[i] = A[i - 1]; build(); return; } int get(int st, int en, int node = 1, int l = 1, int r = n){ int mid = (l + r) / 2; if(st <= mid && en > mid){ return Secret(suf[node][mid - st], pref[node][en - mid - 1]); } if(en <= mid) return get(st, en, 2 * node, l, mid); return get(st, en, 2 * node + 1, mid + 1, r); } int Query(int L, int R){ if(L == R) return a[L + 1]; return get(L + 1, R + 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...