Submission #873156

# Submission time Handle Problem Language Result Execution time Memory
873156 2023-11-14T14:28:27 Z ace_in_the_hole Secret (JOI14_secret) C++17
0 / 100
368 ms 4744 KB
#include "secret.h"

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include<bits/stdc++.h>
using namespace std;

#define all(v) (v).begin(), (v).end()
#define cst(T) const T&

template<class A, class B> bool umin(A& var, cst(B) val) {
  return (val < var) ? (var = val, true) : false;
}
template<class A, class B> bool umax(A& var, cst(B) val) {
  return (var < val) ? (var = val, true) : false;
}

typedef long long Int;
typedef long double Real;
const int MOD = 2004010501;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class X, class Y> Int random(const X& l, const Y& r) {
  return uniform_int_distribution<Int>(l,r)(rng);
}
#define DBG(x) cerr << #x << " = " << x << ' ';
#define DBGn(x) cerr << #x << " = " << x << '\n';

const int N = 1005;
const int LG = 11;
vector<int> a; int n;

int mask[N], dat[LG][N];
void dnc(int l, int r, int lev) {
  if (l == r) return ;
  int m = (l+r) / 2;
  dat[lev][m] = a[m];
  for (int i = m-1; i >= l; i--)
    dat[lev][i] = Secret(a[i], dat[lev][i+1]);
  dat[lev][m+1] = a[m+1];
  for (int i = m+1; i <= r; i++)
    dat[lev][i] = Secret(dat[lev][i-1], a[i]);
  for (int i = m+1; i <= r; i++)
    mask[i] ^= 1<<lev;
  dnc(l,m, lev+1);
  dnc(m+1,r, lev+1);
}

void Init(int _n, int arr[]) {
  n = _n;
  a.insert(end(a), arr, arr+n);
  dnc(0, n-1, 0);
}

int Query(int L, int R) {
  if (L == R) return a[L];
  int lev = __builtin_ctz(mask[L] ^ mask[R]);
  return Secret(dat[lev][L], dat[lev][R]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 2812 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 318854190.
2 Incorrect 93 ms 2640 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 534774241.
3 Incorrect 94 ms 2652 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 204699730.
4 Incorrect 356 ms 4368 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 273285253.
5 Incorrect 352 ms 4720 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 509231116.
6 Incorrect 347 ms 4364 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 707400362.
7 Incorrect 363 ms 4744 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 9155594.
8 Incorrect 350 ms 4352 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 828815616.
9 Incorrect 354 ms 4436 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 700983590.
10 Incorrect 368 ms 4344 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 813517315.