Submission #489562

# Submission time Handle Problem Language Result Execution time Memory
489562 2021-11-23T08:54:21 Z danikoynov Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;
const int maxn = 1010, maxlog = 15;


int dp[maxlog][maxn], arr[maxn], n;

void divide(int left, int right, int depth)
{
    if (left == right)
    {
        dp[depth][left] = arr[left];
        return;
    }

    int mid = (left + right) / 2;
    dp[depth][mid] = arr[mid];
    for (int i = mid - 1; i >= left; i --)
    {
        dp[depth][i] = Secret(arr[i], dp[depth][i + 1]);
        ///cout << depth << " " << i << " " << arr[i] << " " << dp[depth][i + 1] << endl;
    }
    dp[depth][mid + 1] = arr[mid + 1];
    for (int i = mid + 2; i <= right; i ++)
        dp[depth][i] = Secret(arr[i], dp[depth][i - 1]);

    divide(left, mid, depth + 1);
    divide(mid + 1, right, depth + 1);
}

void Init(int m, int a[])
{
    n = m;
    for (int i = 0; i < n; i ++)
        arr[i] = a[i];

    divide(0, n - 1, 1);
}

int Query(int l, int r)
{
    int lf = 0, rf = n - 1, depth = 1;
    while(true)
    {
        int mf = (lf + rf) / 2;

        if (lf == rf)
        {
            return dp[depth][lf];
        }
        if (r <= mf)
        {
            rf = mf;
            depth ++;
            continue;
        }
        if (l > mf)
        {
            lf = mf + 1;
            depth ++;
            continue;
        }

        int ans = Secret(dp[depth][l], dp[depth][r]);
        return ans;
    }
    return 0;
}

Compilation message

secret.cpp: In function 'void divide(int, int, int)':
secret.cpp:21:24: error: 'Secret' was not declared in this scope
   21 |         dp[depth][i] = Secret(arr[i], dp[depth][i + 1]);
      |                        ^~~~~~
secret.cpp:26:24: error: 'Secret' was not declared in this scope
   26 |         dp[depth][i] = Secret(arr[i], dp[depth][i - 1]);
      |                        ^~~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:65:19: error: 'Secret' was not declared in this scope
   65 |         int ans = Secret(dp[depth][l], dp[depth][r]);
      |                   ^~~~~~