Submission #774462

# Submission time Handle Problem Language Result Execution time Memory
774462 2023-07-05T18:18:52 Z colossal_pepe Secret (JOI14_secret) C++17
0 / 100
363 ms 12316 KB
#include "secret.h"
#include <vector>
using namespace std;

int n;
vector<vector<int>> tree(4005);

void buildTree(int node, int l, int r, int a[]) {
    tree[node].resize(n);
    if (node % 2) {
        tree[node][l] = a[l];
        for (int i = l + 1; i <= r; i++) {
            tree[node][i] = Secret(tree[node][i - 1], a[i]);
        }
    } else {
        tree[node][r] = a[r];
        for (int i = r - 1; i >= l; i--) {
            tree[node][i] = Secret(tree[node][i + 1], a[i]);
        }
    }
    if (l != r) {
        int mid = (l + r) / 2;
        buildTree(2 * node, l, mid, a);
        buildTree(2 * node + 1, mid + 1, r, a);
    }
}

int query(int node, int l, int r, int L, int R) {
    if (l == r) return tree[node][l];
    int mid = (l + r) / 2;
    if (R <= mid) return query(2 * node, l, mid, L, R);
    else if (L > mid) return query(2 * node + 1, mid + 1, r, L, R);
    else return Secret(tree[2 * node][L], tree[2 * node + 1][R]);
}

void Init(int N, int A[]) {
    n = N;
    buildTree(2, 0, (n - 1) / 2, A);
    buildTree(3, ((n - 1) / 2) + 1, n - 1, A);
}

int Query(int L, int R) {
    return query(1, 0, n - 1, L, R);
}
# Verdict Execution time Memory Grader output
1 Incorrect 97 ms 4576 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 97 ms 4536 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 95 ms 4588 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 352 ms 12252 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 357 ms 12212 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 354 ms 12292 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 363 ms 12316 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 360 ms 12204 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 355 ms 12220 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 355 ms 12244 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.