답안 #34340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
34340 2017-11-10T06:13:59 Z aome 비밀 (JOI14_secret) C++14
100 / 100
636 ms 9956 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 179 ms 9956 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 179 ms 9956 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 176 ms 9956 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 626 ms 9956 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 636 ms 9956 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 636 ms 9956 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 629 ms 9956 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 609 ms 9956 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 609 ms 9956 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 613 ms 9956 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1