Submission #361851

# Submission time Handle Problem Language Result Execution time Memory
361851 2021-01-31T18:31:42 Z Lemur95 Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define x first
#define y second
#define ld long double
#define ll long long
#define ull unsigned long long
#define us unsigned short
#define lsb(x) ((x) & (-(x)))

using namespace std;

int n;

int v[1005], sum[1005][1005];

/*int Secret(int x, int y) {
  return x ^ y;
}*/

void divide(int st, int dr) {
  if(st == dr) {
    sum[st][st] = v[st];
    return;
  }
  int mid = (st + dr) >> 1;
  sum[mid][mid] = v[mid];
  for(int i = mid - 1; i >= st; i--)
    sum[i][mid] = Secret(sum[i + 1][mid], v[i]);
  if(mid < n - 1)
    sum[mid + 1][mid + 1] = v[mid + 1];
  for(int i = mid + 2; i <= dr; i++)
    sum[mid + 1][i] = Secret(sum[mid + 1][i - 1], v[i]);
}

void init(int N, int a[]) {
  n = N;
  for(int i = 0; i < n; i++)
    v[i] = a[i];
  divide(0, n - 1);
}

int solve(int st, int dr, int l, int r) {
  int mid = (st + dr) >> 1;
  if(l <= mid && mid <= r) {
    if(l == mid || mid == r)
      return sum[l][r];
    else
      return Secret(sum[l][mid], sum[mid + 1][r]);
  }
  if(r < mid)
    return solve(st, mid, l, r);
  return solve(mid + 1, dr, l, r);
}

int Query(int l, int r) {
  if(l == r)
    return v[l];
  return solve(0, n - 1, l, r);
}

/*int main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, Q, l, r, a[10005];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i];
  init(n, a);
  cin >> Q;
  for(; Q; Q--) {
    cin >> l >> r;
    cout << Query(l, r) << "\n";
    int s = v[l];
    for(int i = l + 1; i <= r; i++)
      s = Secret(s, v[i]);
    cout << s << " right answer\n";
  }
  return 0;
}*/

Compilation message

secret.cpp: In function 'void divide(int, int)':
secret.cpp:29:19: error: 'Secret' was not declared in this scope
   29 |     sum[i][mid] = Secret(sum[i + 1][mid], v[i]);
      |                   ^~~~~~
secret.cpp:33:23: error: 'Secret' was not declared in this scope
   33 |     sum[mid + 1][i] = Secret(sum[mid + 1][i - 1], v[i]);
      |                       ^~~~~~
secret.cpp: In function 'int solve(int, int, int, int)':
secret.cpp:49:14: error: 'Secret' was not declared in this scope
   49 |       return Secret(sum[l][mid], sum[mid + 1][r]);
      |              ^~~~~~