Submission #1110542

# Submission time Handle Problem Language Result Execution time Memory
1110542 2024-11-09T21:18:22 Z vladilius Secret (JOI14_secret) C++17
0 / 100
20000 ms 4520 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second

vector<vector<int>> x;
vector<int> a;
int n, lg;

void build(int d, int l, int r){
    if (abs(l - r) <= 1) return;
    int m = (l + r) / 2;
    x[d][m] = a[m];
    for (int i = m - 1; i >= l; i--){
        x[d][i] = Secret(x[d][i + 1], a[i]);
    }
    x[d][m + 1] = a[m + 1];
    for (int i = m + 2; i <= r; i++){
        x[d][i] = Secret(x[d][i - 1], a[i]);
    }
    
    build(d + 1, l, m);
    build(d + 1, m + 1, r);
}

void Init(int ns, int A[]){
    n = ns;
    a.resize(n + 1);
    for (int i = 1; i <= n; i++){
        a[i] = A[i - 1];
    }
    
    lg = log2(n);
    x.resize(lg + 1);
    for (int i = 0; i <= lg; i++){
        x[i].resize(n + 1);
    }
    build(0, 1, n);
}

int get(int d, int tl, int tr, int& l, int& r){
    int tm = (tl + tr) / 2;
    if (l <= tm && tm < r){
        return Secret(x[d][l], x[d][r]);
    }
    return (r <= tm) ? get(d + 1, tl, tm, l, r) : get(d + 1, tm + 1, tr, l, r);
}

int Query(int l, int r){
    l++; r++;
    if ((l + 1) == r) return Secret(a[l], a[r]);
    return get(0, 1, n, l, r);
}
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 2820 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 78 ms 2824 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 79 ms 2824 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 297 ms 4424 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 312 ms 4368 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Execution timed out 20030 ms 4456 KB Time limit exceeded
7 Incorrect 303 ms 4424 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 291 ms 4520 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 297 ms 4496 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 297 ms 4308 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.