Submission #926635

# Submission time Handle Problem Language Result Execution time Memory
926635 2024-02-13T12:50:21 Z myst6 Secret (JOI14_secret) C++17
100 / 100
366 ms 4612 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include "secret.h"

const int maxn = 1000;
int table[10][maxn];
int mask[maxn];
int base[maxn];
int B = 0;

void fill(int L, int R) {
  if (L == R) return;
  int M = (L + R) / 2;
  table[B][M] = base[M];
  table[B][M+1] = base[M+1];
  for (int i=M-1; i>=L; i--) table[B][i] = Secret(base[i], table[B][i+1]);
  for (int i=M+2; i<=R; i++) table[B][i] = Secret(table[B][i-1], base[i]);
  for (int i=M+1; i<=R; i++) mask[i] ^= 1 << B;
  ++B; fill(L, M); fill(M+1, R); --B;
}

void Init(int N, int A[]) {
  for (int i=0; i<N; i++) base[i] = A[i];
  fill(0, N-1);
}

int Query(int L, int R) {
  if (L == R) return base[L];
  int B = __builtin_ctz(mask[L] ^ mask[R]);
  return Secret(table[B][L], table[B][R]);
}
# Verdict Execution time Memory Grader output
1 Correct 103 ms 3668 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 103 ms 3568 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 102 ms 3536 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 360 ms 4432 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 362 ms 4444 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 358 ms 4364 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 366 ms 4376 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 361 ms 4612 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 366 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 360 ms 4428 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1