Submission #810332

#TimeUsernameProblemLanguageResultExecution timeMemory
810332hariaakas646Secret (JOI14_secret)C++17
0 / 100
20083 ms4456 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, j, k) for (int i = j; i < k; i++) #define frange(i, j) forr(i, 0, j) #define all(cont) cont.begin(), cont.end() #define mp make_pair #define pb push_back #define f first #define s second typedef long long int lli; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<lli> vll; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vi> vvi; typedef map<int, int> mpii; typedef set<int> seti; typedef multiset<int> mseti; typedef long double ld; vvi vec; int n; vi Av; void rec(int l, int r, int d) { if (l == r) { vec[d][l] = Av[l]; return; } int mid = (l + r) / 2; vec[d][mid] = Av[mid]; for (int i = mid - 1; i >= l; i--) { vec[d][i] = Secret(Av[i], vec[d][i + 1]); } if (r >= mid + 1) vec[d][mid + 1] = Av[mid + 1]; forr(i, mid + 2, r + 1) { vec[d][i] = Secret(Av[i], vec[d][i - 1]); } rec(l, mid, d + 1); rec(mid + 1, r, d + 1); } int query(int l, int r, int lx, int rx, int d) { int mid = (l + r) / 2; if (lx <= mid && r > mid) { return Secret(vec[lx][d], vec[rx][d]); } if (lx <= mid) return query(l, mid, lx, rx, d + 1); else return query(mid + 1, r, lx, rx, d + 1); } void Init(int N, int a[]) { int n = N; Av = vi(n); frange(i, n) Av[i] = a[i]; vec = vvi(n, vi(11)); rec(0, n - 1, 0); } int Query(int L, int R) { return query(0, n - 1, L, R, 0); }
#Verdict Execution timeMemoryGrader output
Fetching results...