Submission #487170

# Submission time Handle Problem Language Result Execution time Memory
487170 2021-11-14T18:47:26 Z Victor Secret (JOI14_secret) C++17
0 / 100
449 ms 8604 KB
#include "secret.h"

#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b - 1); i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;

const int INF = 1'000'000'007;

int precomp[11][1001], nums[1001];
int n;

void dnc(int lo, int hi, int level) {
    if (lo >= hi) return;

    int mid = (lo + hi) / 2;
    assert(precomp[level][mid]==-1);
    precomp[level][mid] = nums[mid];
    per(i, lo, mid) assert(precomp[level][i]==-1), precomp[level][i] = Secret(nums[i], precomp[level][i + 1]);

    precomp[level][mid + 1] = nums[mid + 1];
    assert(precomp[level][mid+1]==-1);
    rep(i, mid + 2, hi + 1) assert(precomp[level][i]==-1), precomp[level][i] = Secret(nums[i], precomp[level][i - 1]);

    dnc(lo, mid, level - 1);
    dnc(mid + 1, hi, level - 1);
}

void Init(int N, int A[]) {
    memset(precomp,-1,sizeof(precomp));
    rep(i, 0, N) nums[i] = A[i];
    dnc(0, N - 1, 10);
    n = N;
}

int Query(int L, int R) {
    if (L == R) return nums[L];

    int lo = 0, hi = n - 1, level = 10;
    while (1) {
        int mid = (lo + hi) / 2;
        if (L <= mid && mid < R) return Secret(precomp[level][L], precomp[level][R]);
        if (R <= mid)
            hi = mid;
        else
            lo = mid + 1;
        --level;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 111 ms 4728 KB Execution killed with signal 6
2 Runtime error 112 ms 4744 KB Execution killed with signal 6
3 Runtime error 120 ms 4712 KB Execution killed with signal 6
4 Runtime error 423 ms 8588 KB Execution killed with signal 6
5 Runtime error 419 ms 8564 KB Execution killed with signal 6
6 Runtime error 449 ms 8592 KB Execution killed with signal 6
7 Runtime error 414 ms 8604 KB Execution killed with signal 6
8 Runtime error 420 ms 8596 KB Execution killed with signal 6
9 Runtime error 415 ms 8584 KB Execution killed with signal 6
10 Runtime error 427 ms 8584 KB Execution killed with signal 6