# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1067626 | Thunnus | Secret (JOI14_secret) | C++17 | 311 ms | 8280 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
//#define int i64
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define pii pair<int, int>
#define fi first
#define se second
#define sz(x) (int)(x).size()
const int MX = 1e3 + 3;
int n, dp[MX][MX];
inline void divide(int le, int ri, int A[]){
int mid = (le + ri) / 2;
dp[mid][mid] = A[mid], dp[mid + 1][mid + 1] = A[mid + 1];
for(int i = mid - 1; i >= le; i--){
dp[mid][i] = Secret(dp[mid][i + 1], A[i]);
}
for(int i = mid + 2; i <= ri; i++){
dp[mid + 1][i] = Secret(dp[mid + 1][i - 1], A[i]);
}
if(le < mid) divide(le, mid, A);
if(mid + 1 < ri) divide(mid + 1, ri, A);
}
void Init(int N, int A[]){
n = N;
divide(0, n - 1, A);
}
int Query(int L, int R){
int le = 0, ri = n - 1, mid;
while(ri > le){
mid = (ri + le) / 2;
if(le <= mid && ri > mid) return Secret(dp[mid][le], dp[mid + 1][ri]);
if(mid == ri) return dp[mid][le];
if(mid < le)
le = mid + 1;
else
ri = mid;
}
return dp[le][le];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |