답안 #146696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146696 2019-08-25T09:23:51 Z dolphingarlic 비밀 (JOI14_secret) C++14
0 / 100
1044 ms 524296 KB
#include "secret.h"

int prefix[1000][1000], n;

void populate(int L, int R, int A[]) {
    int mid = (L + R) / 2;
    prefix[mid][mid] = A[mid];
    prefix[mid + 1][mid + 1] = A[mid + 1];

    for (int i = mid + 2; i <= R; i++) prefix[mid + 1][i] = Secret(prefix[mid + 1][i - 1], A[i]);
    for (int i = mid - 1; i >= L; i--) prefix[mid][i] = Secret(A[i], prefix[mid][i + 1]);

    if (L <= mid) populate(L, mid, A);
    if (mid + 1 <= R) populate(mid + 1, R, A);
}

void Init(int N, int A[]) {
    n = N;
    populate(0, N - 1, A);
}

int Query(int L, int R) {
    int a = 0, b = n - 1;

    while (a != b) {
        int mid = (a + b) / 2;
        if (mid >= L && mid < R) return Secret(prefix[mid][L], prefix[mid + 1][R]);
        else if (mid == R) return prefix[mid][L];
        else if (mid < L) a = mid + 1;
        else b = mid;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 643 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 637 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 615 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 1039 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 1044 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 1036 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 1032 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 1029 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 1028 ms 524288 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 1033 ms 524296 KB Execution killed with signal 9 (could be triggered by violating memory limits)