# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
749019 | mariowong | Secret (JOI14_secret) | C++14 | 470 ms | 4760 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
map <pair<int,int>,pair<int,bool> > m;
void ask(int l,int r,int A[]){
int mid=(l+r)/2;
if (l != r){
ask(l,mid,A);
ask(mid+1,r,A);
}
int val=A[r];
for (int i=r-1;i>=l;i--){
if (!m[{i,r}].second){
val=Secret(A[i],r);
m[{i,r}]={val,true};
}
}
}
void Init(int N, int A[]) {
m.clear();
int mid=(N-1)/2;
for (int i=0;i<N;i++) m[{i,i}]={A[i],true};
ask(0,mid,A);
ask(mid+1,N-1,A);
}
int Query(int L, int R) {
if (m[{L,R}].second) return m[{L,R}].first;
for (int i=L;i<R;i++){
if (m[{L,i}].second && m[{i+1,R}].second) return Secret(m[{L,i}].first,m[{i+1,R}].first);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |