Submission #810332

# Submission time Handle Problem Language Result Execution time Memory
810332 2023-08-06T08:32:25 Z hariaakas646 Secret (JOI14_secret) C++17
0 / 100
20000 ms 4456 KB
#include <bits/stdc++.h>
#include "secret.h"

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;

vvi vec;
int n;
vi Av;

void rec(int l, int r, int d)
{
  if (l == r)
  {
    vec[d][l] = Av[l];
    return;
  }
  int mid = (l + r) / 2;
  vec[d][mid] = Av[mid];
  for (int i = mid - 1; i >= l; i--)
  {
    vec[d][i] = Secret(Av[i], vec[d][i + 1]);
  }
  if (r >= mid + 1)
    vec[d][mid + 1] = Av[mid + 1];
  forr(i, mid + 2, r + 1)
  {
    vec[d][i] = Secret(Av[i], vec[d][i - 1]);
  }
  rec(l, mid, d + 1);
  rec(mid + 1, r, d + 1);
}

int query(int l, int r, int lx, int rx, int d)
{
  int mid = (l + r) / 2;
  if (lx <= mid && r > mid)
  {
    return Secret(vec[lx][d], vec[rx][d]);
  }
  if (lx <= mid)
    return query(l, mid, lx, rx, d + 1);
  else
    return query(mid + 1, r, lx, rx, d + 1);
}

void Init(int N, int a[])
{
  int n = N;
  Av = vi(n);
  frange(i, n) Av[i] = a[i];

  vec = vvi(n, vi(11));
  rec(0, n - 1, 0);
}

int Query(int L, int R)
{
  return query(0, n - 1, L, R, 0);
}
# Verdict Execution time Memory Grader output
1 Execution timed out 20065 ms 2476 KB Time limit exceeded
2 Execution timed out 20083 ms 2488 KB Time limit exceeded
3 Execution timed out 20024 ms 2380 KB Time limit exceeded
4 Execution timed out 20008 ms 4456 KB Time limit exceeded
5 Execution timed out 20053 ms 4368 KB Time limit exceeded
6 Execution timed out 20037 ms 4428 KB Time limit exceeded
7 Execution timed out 20050 ms 4364 KB Time limit exceeded
8 Execution timed out 20039 ms 4372 KB Time limit exceeded
9 Execution timed out 20030 ms 4404 KB Time limit exceeded
10 Execution timed out 20028 ms 4432 KB Time limit exceeded