Submission #1032013

#TimeUsernameProblemLanguageResultExecution timeMemory
1032013juicySecret (JOI14_secret)C++17
100 / 100
299 ms8532 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; dc(l, md); dc(md + 1, r); F[md][md] = a[md]; for (int i = md - 1; i >= l; --i) { if (F[i][md] == -1) { F[i][md] = Secret(a[i], F[i + 1][md]); } } F[md + 1][md + 1] = a[md + 1]; for (int i = md + 2; i <= r; ++i) { if (F[md + 1][i] == -1) { F[md + 1][i] = Secret(F[md + 1][i - 1], a[i]); } } } int Query(int L, int R) { for (int K = L; K < R; ++K) { if (F[L][K] != -1 && F[K + 1][R] != -1) { return Secret(F[L][K], F[K + 1][R]); } } 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)); for (int i = 0; i < n; ++i) { F[i][i] = a[i]; } dc(); }
#Verdict Execution timeMemoryGrader output
Fetching results...