Submission #915934

#TimeUsernameProblemLanguageResultExecution timeMemory
915934OAleksaSecret (JOI14_secret)C++14
100 / 100
400 ms8440 KiB
#include "secret.h" #include <bits/stdc++.h> //vaso daso gej using namespace std; #define f first #define s second const int N = 1010; int n, a[N], val[N][N]; void solve(int L, int R) { if (R - L <= 1) return; int mid = (L + R) / 2; for (int i = mid - 1;i >= L;i--) val[i][mid] = Secret(a[i], val[i + 1][mid]); for (int i = mid + 2;i <= R;i++) val[mid + 1][i] = Secret(val[mid + 1][i - 1], a[i]); solve(L, mid); solve(mid + 1, R); } void Init(int N, int A[]) { n = N; for (int i = 0;i < n;i++) { a[i] = A[i]; val[i][i] = a[i]; } solve(0, n - 1); } int Query(int L, int R) { if (L == R) return a[L]; else if (R == L + 1) return Secret(a[L], a[R]); for (int i = L;i <= R;i++) { for (int j = i + 1;j <= R;j++) { if (val[i][j - 1] > 0 && val[j][R]) return Secret(val[i][j - 1], val[j][R]); } } }

Compilation message (stderr)

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