Submission #810369

# Submission time Handle Problem Language Result Execution time Memory
810369 2023-08-06T08:53:06 Z hariaakas646 Secret (JOI14_secret) C++17
0 / 100
440 ms 4360 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)
    return;
  // if (d >= 10)
  // {
  //   printf("Problem %d %d\n", l, r);
  //   return;
  // }
  if (l == r)
  {
    vec[l][d] = Av[l];
    return;
  }
  int mid = (l + r) / 2;
  vec[mid][d] = Av[mid];
  for (int i = mid - 1; i >= l; i--)
  {
    vec[i][d] = Secret(Av[i], vec[i + 1][d]);
  }
  if (r >= mid + 1)
    vec[mid + 1][d] = Av[mid + 1];
  forr(i, mid + 2, r + 1)
  {
    vec[i][d] = Secret(Av[i], vec[i - 1][d]);
  }
  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 (d >= 10)
  // {
  //   printf("%d %d %d %d\n", l, r, lx, rx);
  //   return 0;
  // }
  // if(lx == rx) return
  if (lx == rx)
  {
    return Av[lx];
  }
  if (lx <= mid && rx > 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[])
{
  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 Incorrect 112 ms 2284 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 101 ms 2328 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 120 ms 2400 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 404 ms 4324 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 440 ms 4332 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 391 ms 4300 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 406 ms 4300 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 397 ms 4296 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 395 ms 4360 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 411 ms 4324 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.