Submission #341850

#TimeUsernameProblemLanguageResultExecution timeMemory
341850ronnithSecret (JOI14_secret)C++14
100 / 100
510 ms4584 KiB
#include <bits/stdc++.h> #include "secret.h" #define FOR(i,a,b) for(int i = (a);i < (b);i ++) #define ROF(i,a,b) for(int i = (a);i >= (b);i --) #define trav(a, b) for(auto a : b) #define sz(a) int((a).size()) #define all(a) (a).begin(), (a).end() #define pb push_back #define mk make_pair #define f first #define s second using namespace std; typedef long long ll; int n; int dat[11][1000]; void divi(int lvl, int lx, int rx, int *a){ if(lx == rx){ dat[lvl][lx] = a[lx]; return; } int mid = lx + (rx - lx) / 2; ROF(i,mid,lx){ if(i == mid)dat[lvl][i] = a[i]; else dat[lvl][i] = Secret(a[i], dat[lvl][i + 1]); } FOR(i,mid + 1,rx + 1){ if(i == mid + 1)dat[lvl][i] = a[i]; else dat[lvl][i] = Secret(dat[lvl][i - 1], a[i]); } divi(lvl + 1, lx, mid, a);divi(lvl + 1, mid + 1, rx, a); } void Init(int N, int a[]) { n = N; divi(0,0,n - 1,a); } int query(int lvl, int l, int r, int lx, int rx){ int mid = lx + (rx - lx) / 2; if(r >= mid && l <= mid){ int res = dat[lvl][l]; if(r > mid)res = Secret(res, dat[lvl][r]); return res; } if(r < mid)return query(lvl + 1, l, r, lx, mid); else return query(lvl + 1, l, r, mid + 1, rx); } int Query(int l, int r) { return query(0,l,r,0,n - 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...