#include "secret.h"
#include <bits/stdc++.h>
#include <random>
#define ll long long
// #define int long long
#define fi first
#define se second
#define pb push_back
#define md ((l+r)>>1)
#define lf (id<<1)
#define rg ((id<<1)|1)
#define ld long double
using namespace std;
typedef pair<ll,ll> pii;
typedef pair<pii,pii> ipii;
const ll MAXN = 1e3+10;
const ll MAXA = 1e6+10;
const ll INF = 2e18+10;
const ll LOG = 30;
const ll MOD = 1e9+7;
ll n;
ll a[MAXN], dep[MAXN];
map <pii, ll> m;
void bd(ll DEP, ll l, ll r){
if(l>r) return;
// cout << DEP << ' ' << l << ' ' << r << " pp\n";
ll mid = md;
dep[mid] = DEP;
if(l==r) return;
ll val = a[mid];
for(ll i=mid-1; i>=l; i--){
val = Secret(a[i], val); // ke kiri
m[pii(i, mid)] = val;
}
val = a[mid+1];
for(ll i=mid+2; i<=r; i++){
val = Secret(val, a[i]); // ke kanan
m[pii(mid+1, i)] = val;
}
bd(DEP+1, l, mid-1); bd(DEP+1, mid+1, r);
}
void Init(int N, int x[]) {
n = N;
for(ll i=0; i<n; i++){
a[i+1] = x[i]; m[pii(i+1, i+1)] = x[i];
}
bd(1, 1, n);
// for(ll i=1; i<=n; i++) cout << dep[i] << " \n"[i==n];
}
int Query(int L, int R) {
L++; R++;
ll idx = -1, mn = INF;
for(ll i=L; i<=R; i++){
if(mn > dep[i]){
idx = i;
mn = dep[i];
}
}
return (int)Secret(m[pii(L, idx)], m[pii(idx+1, R)]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
110 ms |
2724 KB |
Wrong Answer: Query(264, 271) - expected : 675707686, actual : 4619042. |
2 |
Incorrect |
100 ms |
2724 KB |
Wrong Answer: Query(210, 211) - expected : 558550312, actual : 558532904. |
3 |
Incorrect |
99 ms |
2736 KB |
Wrong Answer: Query(130, 131) - expected : 127065177, actual : 93509720. |
4 |
Incorrect |
378 ms |
5204 KB |
Wrong Answer: Query(571, 624) - expected : 309502044, actual : 309493852. |
5 |
Incorrect |
370 ms |
4732 KB |
Wrong Answer: Query(584, 592) - expected : 111053842, actual : 110791698. |
6 |
Incorrect |
379 ms |
5020 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 278446241. |
7 |
Correct |
383 ms |
4704 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
398 ms |
4948 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
387 ms |
4776 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
390 ms |
4920 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |