Submission #852730

# Submission time Handle Problem Language Result Execution time Memory
852730 2023-09-22T15:35:28 Z sleepntsheep Secret (JOI14_secret) C++17
0 / 100
20000 ms 4496 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 <= x && y <= m) return qry(vl, l, m, x, y);
    if (m + 1 <= x && y <= r) return qry(vr, m+1, r, x, y);

    int al = suf[vl][suf[vl].size()-1-(m-x)], ar = pre[vr][y-m-1];
    return Secret(al, ar);
}

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 Incorrect 100 ms 3608 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 273765800.
2 Incorrect 98 ms 3668 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 720449952.
3 Incorrect 99 ms 3908 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 688267566.
4 Incorrect 369 ms 4496 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 379765294.
5 Incorrect 367 ms 4420 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 173572114.
6 Execution timed out 20023 ms 4420 KB Time limit exceeded
7 Incorrect 376 ms 4428 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 224959569.
8 Incorrect 366 ms 4432 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273092952.
9 Incorrect 369 ms 4432 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 12848836.
10 Incorrect 370 ms 4424 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 699278.