# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003692 | MarwenElarbi | Secret (JOI14_secret) | C++17 | 287 ms | 8400 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 <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
const int MAXN=1e5+5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dp[1005][1005];
int n;
int Secret(int X, int Y);
void daq(int l,int r){
if(r-l<2) return;
int mid=(r+l)/2;
dp[mid][mid+1]=dp[mid+1][mid+1];
for (int i = mid+2; i <= r; ++i)
{
dp[mid][i]=Secret(dp[mid][i-1],dp[i][i]);
}
for (int i = mid-1; i >= l ; --i)
{
dp[mid][i]=Secret(dp[i][i],dp[mid][i+1]);
}
daq(l,mid);
daq(mid+1,r);
return;
}
void Init(int N, int A[]) {
n=N;
for (int i = 0; i < N; ++i)
{
dp[i][i]=A[i];
}
daq(0,N-1);
return;
}
int query(int l,int r,int left,int right){
int mid=(r+l)/2;
if(left>mid) return query(mid+1,r,left,right);
else if(right<mid) return query(l,mid,left,right);
else if(left==mid) return Secret(dp[mid][mid],dp[mid][right]);
else if(right==mid) return dp[mid][left];
else{
//cout <<dp[mid][right]<<" "<<dp[mid][left]<<endl;
return Secret(dp[mid][left],dp[mid][right]);
}
}
int Query(int L, int R) {
if(R==L) return dp[L][L];
else if(R-L==1) return Secret(dp[L][L],dp[R][R]);
else{
return query(0,n-1,L,R);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |