Submission #368056

# Submission time Handle Problem Language Result Execution time Memory
368056 2021-02-19T12:01:51 Z RyoPham Secret (JOI14_secret) C++14
0 / 100
507 ms 4740 KB
#include <bits/stdc++.h>
#include "secret.h"

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 1005;

int n;
int a[maxn], B[maxn];

vector<int> left_val[maxn * 4], right_val[maxn * 4];

int cnt = 0;

void dnc(int x, int l, int r)
{
    if(l == r) return;
    int mid = (l + r) / 2;
    left_val[x].push_back(a[mid]);
    for(int i = mid - 1; i >= l; --i)
        left_val[x].push_back(Secret(left_val[x].back(), a[i]));
    right_val[x].push_back(a[mid + 1]);
    for(int i = mid + 2; i <= r; ++i)
        right_val[x].push_back(Secret(right_val[x].back(), a[i]));
    //cnt += sz(left_val[x]) - 1; cnt += sz(right_val[x]) - 1;
    dnc(x * 2, l, mid);
    dnc(x * 2 + 1, mid + 1, r);
}

int get(int x, int l, int r, int L, int R)
{
    assert(l < r);
    int mid = (l + r) / 2;
    if(L <= mid && R > mid)
        return Secret(left_val[x][mid - L], right_val[x][R - mid - 1]);
    if(R <= mid)
        return get(x * 2, l, mid, L, R);
    return get(x * 2 + 1, mid + 1, r, L, R);
}

void Init(int N, int A[])
{
    n = N;
    for(int i = 0; i < n; ++i)
        a[i] = A[i];
    dnc(1, 0, n - 1);
}

int Query(int L, int R)
{
    if(L == R) return a[L];
    return get(1, 0, n - 1, L, R);
}
# Verdict Execution time Memory Grader output
1 Incorrect 136 ms 2668 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 136 ms 2668 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 138 ms 2924 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 496 ms 4716 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 503 ms 4716 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 502 ms 4716 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 504 ms 4716 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 507 ms 4716 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 499 ms 4740 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 500 ms 4716 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.