답안 #59352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
59352 2018-07-21T16:33:13 Z gusfring 비밀 (JOI14_secret) C++14
100 / 100
735 ms 9716 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
 
int n;
int f[1005][1005];
int a[1005];
 
void solve(int l, int r) {
    if (l > r) return;
    if (l == r) {
        f[l][l] = a[l]; return;
    }
    int mid = (l + r) / 2;
    solve(l, mid), solve(mid + 1, r);
    for (int i = mid - 1; i >= l; --i) {
        f[i][mid] = Secret(a[i], f[i + 1][mid]);
    }
    for (int i = mid + 2; i <= r; ++i) {
        f[mid + 1][i] = Secret(f[mid + 1][i - 1], a[i]);
    }
}
 
int Query(int l, int r){
    for (int i = l; i < r; ++i){
        if (f[l][i] != -1 && f[i + 1][r] != -1) {
            return Secret(f[l][i], f[i + 1][r]);
        }
    }
    return f[l][r];
}
 
void Init(int N, int A[]) {
    memset(f, -1, sizeof(f));
    n = N; for (int i = 0; i < n; ++i) a[i] = A[i];
    solve(0, n - 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 6412 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 203 ms 6844 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 192 ms 6844 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 661 ms 8840 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 691 ms 9092 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 718 ms 9236 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 735 ms 9352 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 668 ms 9352 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 727 ms 9384 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 653 ms 9716 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1