Submission #751904

#TimeUsernameProblemLanguageResultExecution timeMemory
751904Markomafko972Secret (JOI14_secret)C++14
0 / 100
474 ms8328 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; int n; int a[1005]; int val[1005][1005]; void rek(int l, int r) { if (l >= r) return; int mid = (l+r)/2; for (int j = mid-1; j >= l; j--) { val[j][mid] = Secret(val[j+1][mid], a[j]); } for (int j = mid+2; j <= r; j++) { val[mid+1][j] = Secret(val[mid+1][j-1], a[j]); } rek(l, mid); rek(mid+1, r); } void Init(int N, int A[]) { n = N; memset(val, -1, sizeof val); for (int i = 0; i < n; i++) { a[i] = A[i]; val[i][i] = a[i]; } rek(0, n-1); } int Query(int l, int r) { if (val[l][r] != -1) return val[l][r]; for (int i = l; i < r; i++) { if (val[l][i] != -1 && val[i+1][r] != -1) return Secret(val[l][i], val[i+1][r]); } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...