# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
380499 | pure_mem | 비밀 (JOI14_secret) | C++14 | 537 ms | 9468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "secret.h"
#include <bits/stdc++.h>
#define X first
#define Y second
#define MP make_pair
#define ll long long
using namespace std;
int q[1001][1001];
bool was[1001][1001];
void Init(int N, int A[]) {
stack< pair<int, int> > st;
st.push(MP(1, N));
while(!st.empty()){
int l = st.top().X, r = st.top().Y; st.pop();
int m = (l + r) / 2;
was[m][m] = 1, q[m][m] = A[m - 1];
for(int i = m - 1, j = A[m - 1];i >= l;i--){
j = Secret(A[i - 1], j), q[i][m] = j, was[i][m] = 1;
}
if(l == r)
continue;
was[m + 1][m + 1] = 1, q[m + 1][m + 1] = A[m];
for(int i = m + 2, j = A[m];i <= r;i++){
j = Secret(A[i - 1], j), q[m + 1][i] = j, was[m + 1][i] = 1;
}
if(l != r)
st.push(MP(l, m)), st.push(MP(m + 1, r));
}
// Secret(0, 1000000000);
}
int Query(int L, int R) {
L += 1, R += 1;
if(was[L][R])
return q[L][R];
for(int i = L;i < R;i++){
if(was[L][i] && was[i + 1][R])
return Secret(q[L][i], q[i + 1][R]);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |