# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
935639 |
2024-02-29T10:06:21 Z |
Baizho |
Secret (JOI14_secret) |
C++14 |
|
399 ms |
8528 KB |
#include <bits/stdc++.h>
#include <secret.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
// #pragma GCC optimize("Ofast,unroll-loops,fast-math")
// #pragma GCC target("popcnt")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define sz size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back
const int mod = ll(1e9)+7;
const ll MOD = 998244353;
const long long inf = 5e18;
const int M = 1005;
int Secret(int x, int y);
int val[M][M], n, a[M];
void solve(int l, int r) {
if(l >= r) return;
int mid = (l + r) / 2;
val[mid][mid] = a[mid];
val[mid + 1][mid + 1] = a[mid + 1];
for(int i = mid - 1; i >= l; i --) val[mid][i] = Secret(a[i], val[mid][i + 1]);
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];
solve(0, n - 1);
}
int Query(int L, int R) {
int l = L, r = R, tl = 0, tr = n - 1;
if(l == r) {
return a[l];
}
while(tl != tr) {
int mid = (tl + tr) / 2;
if(l <= mid && mid + 1 <= r) {
// cout<<tl<<" "<<tr<<" "<<mid<<endl;
return Secret(val[mid][l], val[mid + 1][r]);
}
else if(l == mid) return val[mid + 1][r];
else if(r == mid) return val[mid][l];
else if(r <= mid) tr = mid;
else tl = mid + 1;
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
6748 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
109 ms |
6740 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
109 ms |
6740 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
385 ms |
8284 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
381 ms |
8284 KB |
Output is correct - number of calls to Secret by Init = 7978, 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 = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
381 ms |
8272 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
386 ms |
8528 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
390 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
383 ms |
8268 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |