Submission #729941

# Submission time Handle Problem Language Result Execution time Memory
729941 2023-04-24T22:40:26 Z jampm Secret (JOI14_secret) C++17
0 / 100
435 ms 4452 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

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


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) {
  //cout << L << " " << R << endl;
  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 112 ms 2380 KB Wrong Answer: Query(264, 271) - expected : 675707686, actual : 456275163.
2 Incorrect 111 ms 2416 KB Wrong Answer: Query(236, 238) - expected : 173116186, actual : 416517106.
3 Incorrect 114 ms 2360 KB Wrong Answer: Query(128, 153) - expected : 959658850, actual : 219466354.
4 Incorrect 424 ms 4452 KB Wrong Answer: Query(374, 396) - expected : 402362963, actual : 342036658.
5 Incorrect 424 ms 4212 KB Wrong Answer: Query(703, 706) - expected : 857111674, actual : 727225567.
6 Incorrect 419 ms 4304 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 707400362.
7 Correct 435 ms 4208 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 426 ms 4228 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 428 ms 4304 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 430 ms 4260 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1