Submission #538898

#TimeUsernameProblemLanguageResultExecution timeMemory
538898schiftyfive4Secret (JOI14_secret)C++14
0 / 100
466 ms4512 KiB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;

int n;
vector<vector<int>> t(15, vector<int>(1000));

void calc(int L, int R, int dep, int A[]) {
  if (L == R) {
    t[dep][L] = A[L];
    return;
  }
  int m = (L + R) / 2;
  t[dep][m] = A[m];
  for (int i = m - 1; i >= L; i--) {
    t[dep][i] = Secret(A[i], t[dep][i + 1]);
  }
  t[dep][m + 1] = A[m + 1];
  for (int i = m + 2; i <= R; i++) {
    t[dep][i] = Secret(A[i], t[dep][i - 1]);
  }
  calc(L, m, dep + 1, A);
  calc(m + 1, R, dep + 1, A);
}

void Init(int N, int A[]) {
  n = N;
  calc(0, n - 1, 0, A);
}

int get(int L, int R, int qL, int qR, int dep) {
  if (L == R) {
    return t[dep][L];
  }
  int m = (L + R) / 2;
  if (qL <= m && m + 1 <= qR) {
    return Secret(t[dep][qL], t[dep][qR]);
  } else if (qR <= m) {
    return get(L, m, qL, qR, dep + 1);
  }
  return get(m + 1, R, qL, qR, dep + 1);
}

int Query(int L, int R) {
  return get(0, n - 1, L, R, 0);
}

// int main() {
//   ios::sync_with_stdio(false);
//   cin.tie(nullptr);
  
// }
#Verdict Execution timeMemoryGrader output
Fetching results...