답안 #852724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
852724 2023-09-22T15:30:35 Z sleepntsheep 비밀 (JOI14_secret) C++17
6 / 100
6821 ms 4816 KB
#include <vector>
#include "secret.h"
#include <assert.h>
#define N 1050

int n, *a;
std::vector<int> pre[N<<1], suf[N<<1];

void build(int v, int l, int r)
{
    if (l == r)
    {
        pre[v] = suf[v] = {a[l]};
        return;
    }
    int m=(l+r)/2, vl=v+1, vr=v+(m-l+1)*2;
    suf[v].resize(m-l+1);
    suf[v][m-l] = a[m];
    for (int i = m-l-1, j = m - 1; j >= l; --j, --i)
        suf[v][i] = Secret(a[j], suf[v][i+1]);
    pre[v].resize(r-m);
    pre[v][0] = a[m+1];
    for (int i = 1; i < r-m; ++i)
        pre[v][i] = Secret(pre[v][i-1], a[m+1+i]);
    build(vl, l, m);
    build(vr, m+1, r);
}

int qry(int v, int l, int r, int x, int y)
{
    int m = (l+r)/2, vl=v+1, vr=v+(m-l+1)*2;

    if (l == r) assert(y == l);
    if (y == m) return suf[v][suf[v].size() - 1 - (y - x)];
    if (x == m + 1) return pre[v][y - x];


    if (l <= x && y <= m) return qry(vl, l, m, x, y);
    if (m + 1 <= x && y <= r) return qry(vr, m+1, r, x, y);

    return Secret(qry(vl, l, m, x, m), qry(vr, m+1, r, m+1, y));
}

void Init(int n_, int *a_)
{
    n = n_, a = a_;
    build(0, 0, n-1);
}

int Query(int l, int r)
{
    return qry(0, 0, n-1, l, r);
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1263 ms 3920 KB Output isn't correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 506
2 Partially correct 1245 ms 3728 KB Output isn't correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 507
3 Partially correct 1261 ms 3728 KB Output isn't correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 504
4 Partially correct 2693 ms 4816 KB Output isn't correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 997
5 Partially correct 2738 ms 4644 KB Output isn't correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 986
6 Partially correct 387 ms 4432 KB Output is partially correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 10
7 Partially correct 6821 ms 4640 KB Output isn't correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 999
8 Partially correct 6614 ms 4640 KB Output isn't correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 999
9 Partially correct 6554 ms 4644 KB Output isn't correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 998
10 Partially correct 6585 ms 4432 KB Output isn't correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 999