Submission #852727

# Submission time Handle Problem Language Result Execution time Memory
852727 2023-09-22T15:33:24 Z sleepntsheep Secret (JOI14_secret) C++17
6 / 100
394 ms 4688 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;
    pre[v].resize(r-l+1);
    suf[v].resize(r-l+1);
    suf[v][r-l] = a[r];
    for (int i = r-l-1, j = r-1; j >= l; --j, --i)
        suf[v][i] = Secret(a[j], suf[v][i+1]);
    pre[v][0] = a[l];
    for (int i = 1, j = l + 1; j <= r; ++j, ++i)
        pre[v][i] = Secret(pre[v][i-1], a[j]);
    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 == x) return pre[v][y-x];
    if (r == y) return suf[v][suf[v].size()-1-(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);
}

# Verdict Execution time Memory Grader output
1 Partially correct 110 ms 3576 KB Output isn't correct - number of calls to Secret by Init = 8176, maximum number of calls to Secret by Query = 1
2 Partially correct 109 ms 3772 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
3 Partially correct 110 ms 3616 KB Output isn't correct - number of calls to Secret by Init = 8214, maximum number of calls to Secret by Query = 1
4 Partially correct 377 ms 4432 KB Output isn't correct - number of calls to Secret by Init = 17934, maximum number of calls to Secret by Query = 1
5 Partially correct 391 ms 4676 KB Output isn't correct - number of calls to Secret by Init = 17954, maximum number of calls to Secret by Query = 1
6 Partially correct 378 ms 4688 KB Output isn't correct - number of calls to Secret by Init = 17954, maximum number of calls to Secret by Query = 1
7 Partially correct 381 ms 4432 KB Output isn't correct - number of calls to Secret by Init = 17954, maximum number of calls to Secret by Query = 1
8 Partially correct 394 ms 4536 KB Output isn't correct - number of calls to Secret by Init = 17954, maximum number of calls to Secret by Query = 1
9 Partially correct 379 ms 4448 KB Output isn't correct - number of calls to Secret by Init = 17954, maximum number of calls to Secret by Query = 1
10 Partially correct 384 ms 4688 KB Output isn't correct - number of calls to Secret by Init = 17954, maximum number of calls to Secret by Query = 1