Submission #548162

#TimeUsernameProblemLanguageResultExecution timeMemory
548162Alex_tz307Secret (JOI14_secret)C++17
0 / 100
464 ms4512 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; const int kN = 1e3; const int kLog = 20; int n, a[kN], dp[kN][kLog]; void solve(int l, int r, int level) { if (l == r) { return; } int mid = (l + r) / 2; dp[mid][level] = a[mid]; dp[mid + 1][level] = a[mid + 1]; for (int i = mid - 1; i >= l; --i) { dp[i][level] = Secret(dp[i + 1][level], a[i]); } for (int i = mid + 2; i <= r; ++i) { dp[i][level] = Secret(dp[i - 1][level], a[i]); } solve(l, mid, level + 1); solve(mid + 1, r, level + 1); } void Init(int N, int A[]) { n = N; for (int i = 0; i < n; ++i) { a[i] = A[i]; } solve(0, n - 1, 0); } int Query(int l, int r) { if (l == r) { return a[l]; } int st = 0, dr = n - 1, level = 0; while (st <= dr) { int mid = (st + dr) / 2; if (l <= mid && mid < r) { return Secret(dp[l][level], dp[r][level]); } if (mid < l) { st = mid + 1; } else { dr = mid; } level += 1; } }

Compilation message (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
   52 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...