답안 #780704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780704 2023-07-12T11:53:17 Z borisAngelov 비밀 (JOI14_secret) C++17
0 / 100
400 ms 4544 KB
#include "secret.h"
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1024;
const int max_log = 15;

int n;
int a[maxn];

int precompute[maxn][max_log];

void divide(int depth, int l, int r)
{
    if (l == r)
    {
        precompute[l][depth] = a[l];
        return;
    }

    int mid = (l + r) / 2;

    precompute[mid][depth] = a[mid];

    for (int i = mid - 1; i >= l; --i)
    {
        precompute[i][depth] = Secret(precompute[i + 1][depth], a[i]);
    }

    precompute[mid + 1][depth] = a[mid + 1];

    for (int i = mid + 2; i <= r; ++i)
    {
        precompute[i][depth] = Secret(precompute[i - 1][depth], a[i]);
    }

    divide(depth + 1, l, mid);
    divide(depth + 1, mid + 1, r);
}

void Init(int N, int Arr[])
{
    n = N;

    for (int i = 0; i < n; ++i)
    {
        a[i] = Arr[i];
    }

    divide(0, 0, n - 1);
}

int recurse(int depth, int l, int r, int ql, int qr)
{
    if (l == r)
    {
        return precompute[depth][l];
    }

    int mid = (l + r) / 2;

    if (r <= mid)
    {
        return recurse(depth + 1, l, mid, ql, qr);
    }

    if (l >= mid + 1)
    {
        return recurse(depth + 1, mid + 1, r, ql, qr);
    }

    return Secret(precompute[depth][l], precompute[depth][r]);
}

int Query(int L, int R)
{
    int l = L;
    int r = R;

    return recurse(0, 0, n - 1, l, r);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 102 ms 2364 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 559250105.
2 Incorrect 107 ms 2484 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 566235240.
3 Incorrect 101 ms 2476 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 748124652.
4 Incorrect 373 ms 4392 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 910819993.
5 Incorrect 376 ms 4544 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 373297226.
6 Incorrect 373 ms 4400 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 943367779.
7 Incorrect 377 ms 4320 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 612573304.
8 Incorrect 394 ms 4412 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 682694016.
9 Incorrect 400 ms 4400 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 25297934.
10 Incorrect 375 ms 4380 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 873882370.