Submission #1032003

#TimeUsernameProblemLanguageResultExecution timeMemory
1032003juicySecret (JOI14_secret)C++17
0 / 100
336 ms8292 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif int n; int a[1000], F[1000][1000]; bool vs[1000]; void dc(int l = 0, int r = n - 1) { if (l == r) { return; } int md = (l + r) / 2; assert(!vs[md]); vs[md] = 1; F[md][md] = a[md]; F[md + 1][md] = a[md + 1]; for (int i = md - 1; i >= l; --i) { F[i][md] = Secret(a[i], F[i + 1][md]); } for (int i = md + 2; i <= r; ++i) { F[i][md] = Secret(a[i], F[i - 1][md]); } dc(l, md); dc(md + 1, r); } int Query(int L, int R) { for (int K = L; K < R; ++K) { if (F[L][K] != -1 && F[R][K] != -1) { return Secret(F[L][K], F[R][K]); } } return a[L]; } void Init(int _n, int *A) { n = _n; for (int i = 0; i < n; ++i) { a[i] = A[i]; } memset(F, -1, sizeof(F)); dc(); }
#Verdict Execution timeMemoryGrader output
Fetching results...