# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94805 | Retro3014 | 비밀 (JOI14_secret) | C++17 | 493 ms | 9392 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 <vector>
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define MAX_N 1000
vector<int> v;
int n;
int dp[MAX_N+1][MAX_N+1];
bool vst[MAX_N+1][MAX_N+1];
void init(int x, int y){
if(x==y) {
return;
}
if(x==y-1){
return;
}
int m = (x+y)/2;
dp[m][m] = v[m];
dp[m+1][m+1] = v[m+1];
for(int i=m-1; i>=x; i--) {
if(!vst[i][m]){
dp[i][m] = Secret(v[i], dp[i+1][m]);
vst[i][m] = true;
}
}
for(int j=m+2; j<=y; j++){
if(!vst[m+1][j]){
dp[m+1][j] = Secret(dp[m+1][j-1], v[j]);
vst[m+1][j] = true;
}
}
init(x, m);
init(m+1, y);
}
void Init(int N, int A[]) {n = N;
for(int i=0; i<N; i++){
v.push_back(A[i]);
}
init(0, N-1);
}
int Query(int L, int R) {
if(L==R){
return v[L];
}
if(L==R-1){
return Secret(v[L], v[R]);
}
int s = 0, e = n-1, m;
while(1){
m = (s+e)/2;
if(L<=m && R>m){
return Secret(dp[L][m], dp[m+1][R]);
}
if(R<=m){
e = m;
}else{
s = m+1;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |