답안 #852719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
852719 2023-09-22T15:25:37 Z sleepntsheep 비밀 (JOI14_secret) C++17
0 / 100
376 ms 4692 KB
#include <vector>
#include "secret.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)
{
    if (l == r) return a[l];
    int m = (l+r)/2, vl=v+1, vr=v+(m-l+1)*2;

    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, y), qry(vr, m+1, r, x, 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 Incorrect 99 ms 3664 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 822417676.
2 Incorrect 101 ms 3748 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 581013576.
3 Incorrect 100 ms 3776 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 92340494.
4 Incorrect 368 ms 4692 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 892354769.
5 Incorrect 374 ms 4616 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 425741380.
6 Incorrect 369 ms 4688 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 143328322.
7 Incorrect 373 ms 4560 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 139047937.
8 Incorrect 371 ms 4688 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 94721408.
9 Incorrect 376 ms 4656 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 10226400.
10 Incorrect 372 ms 4688 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 877240963.