# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
985771 |
2024-05-18T17:22:37 Z |
tfgs |
Secret (JOI14_secret) |
C++17 |
|
399 ms |
8528 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#endif
#define f first
#define s second
template<class T> using V = vector<T>;
using vi = V<int>;
using vb = V<bool>;
using vs = V<string>;
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T> int lwb(V<T>& a, const T& b) { return lb(all(a),b)-bg(a); }
template<class T> int upb(V<T>& a, const T& b) { return ub(all(a),b)-bg(a); }
const int max_n = 1000;
int range[max_n+1][max_n+1];
void precalc(int l, int r) {
if (l == r-1) return;
int m = (l+r)/2;
for (int i = m-1; i >= l; i--) if (range[i][m] == -1) {
range[i][m] = Secret(range[i][i+1], range[i+1][m]);
}
for (int i = m+1; i <= r; i++) if (range[m][i] == -1) {
range[m][i] = Secret(range[m][i-1], range[i-1][i]);
}
precalc(l, m);
precalc(m, r);
}
void Init(int N, int A[]) {
memset(range, -1, sizeof range);
for (int i = 0; i < N; i++) range[i][i+1] = A[i];
precalc(0, N);
}
int Query(int L, int R) {
for (int i = L+1; i <= R; i++) {
if (range[L][i] != -1 && range[i][R+1] != -1)
return Secret(range[L][i], range[i][R+1]);
}
return range[L][R+1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
8276 KB |
Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
123 ms |
8104 KB |
Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
112 ms |
8288 KB |
Output is correct - number of calls to Secret by Init = 3101, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
381 ms |
8268 KB |
Output is correct - number of calls to Secret by Init = 6989, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
385 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
399 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
387 ms |
8528 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
394 ms |
8272 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
397 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
389 ms |
8272 KB |
Output is correct - number of calls to Secret by Init = 6997, maximum number of calls to Secret by Query = 1 |