Submission #729939

# Submission time Handle Problem Language Result Execution time Memory
729939 2023-04-24T22:30:38 Z jampm Secret (JOI14_secret) C++17
0 / 100
455 ms 4480 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

int const Mxn = 1e3 + 1;
int const LOGN = 11;


int ST[LOGN][Mxn];
int A[Mxn];
int n;

void build(int L = 0, int R = n, int depth = 0) {
  if (L + 1 == R) {
    ST[depth][L] = A[L]; return;
  }
  int Mid = (L + R)>>1;
  for (int i = Mid; i < R; i++) {
    ST[depth][i] = (i == Mid) ? A[i] : Secret(ST[depth][i - 1], A[i]);
  }
  for (int i = Mid - 1; i >= L; i--) {
    ST[depth][i] = (i == Mid - 1) ? A[i] : Secret(A[i], ST[depth][i + 1]);
  }
  build(L, Mid, depth + 1), build(Mid, R, depth + 1);
}
int query(int l, int r, int L = 0, int R = n, int depth = 0) {
  if (L + 1 == R) return A[L];
  int Mid = (L + R)>>1;
  if (l <= Mid && Mid <= r) return Secret(ST[depth][l], ST[depth][r]);
  if (r < Mid) return query(l, r, L, Mid, depth + 1);
  else return query(l, r, Mid, R, depth + 1);
}

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

int Query(int L, int R) {
  return query(L, R);
}

# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 2380 KB Wrong Answer: Query(255, 409) - expected : 307522235, actual : 38999632.
2 Incorrect 115 ms 2400 KB Wrong Answer: Query(236, 238) - expected : 173116186, actual : 416517106.
3 Incorrect 122 ms 2424 KB Wrong Answer: Query(128, 153) - expected : 959658850, actual : 219466354.
4 Incorrect 434 ms 4300 KB Wrong Answer: Query(374, 396) - expected : 402362963, actual : 342036658.
5 Incorrect 446 ms 4300 KB Wrong Answer: Query(937, 999) - expected : 615241818, actual : 827956544.
6 Incorrect 422 ms 4204 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 31281100.
7 Correct 453 ms 4308 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 455 ms 4480 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 439 ms 4324 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 438 ms 4256 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1